So I was going through the settings in the Views Module and hit a checkbox and clicked save. This unfortunately transformed the entire Views UI into my custom theme's homepage. And trying to go into settings does not allow me to see anything except my custom homepage. I've tried uninstalling the module and deleting EVERYTHING but nothing seems to work. How can I manually undo check whatever box I had checked.
it needs a little bit of debugging.
go into views source code, look for .module files and search for
hook_menu() implementation
find there an URL where you have checked that checkbox
go into page callback function
check for submit callback function and go to that function
look for update queries or variables settings, anything that have a machine name of your checkbox, look for the mysql table and field
go into database and update that field to your needs
you can also use a fresh drupal install to perform this, it will be easier to just copy the value from one database field into another
Related
I would like to know what happens when I click on activate on a WordPress-Plugin on "Activate". Which files and functions get Triggered by WordPress.
How I actually think WordPress is working are these steps:
A file and function from WordPress is in a loop which gets triggered like this:
WordPress gets from the main-file the Header-fields and calls a file(which?) with the functions and defines it to the public output with echo or return.
WordPress calls the activation_function. When the user has not defined it then it does nothing.
The main file runs now like each other program.
While the program runs, WordPress has a file/function which gets triggered on "plugin->deactivate" and a function which will look similarly:"
(I am a type of human who likes to play compiler)
(I add a picture because I got only: "Your post appears to contain code that is not properly formatted as code" and could not solve like 10 minutes.)
This "Your post appears to contain code that is not properly formatted as code" is driving me crazy. I had to delete a few things.
I have looked on pages like these but no one goes so deep inside:
https://developer.wordpress.org/plugins/plugin-basics/
I appreciate you are thinking this way.
But before you get any answer to this, may i ask why you are asking this?
Meaning, what you want to understand? Is there any specific thing you want to achieve at plugin activation?
There is not much WordPress does while activating plugin.
WordPress scans each file or top level directory inside plugin directory and looks for header comment
See for more details: https://developer.wordpress.org/plugins/plugin-basics/#getting-started
Once it recognizes a plugin, it offers to activate it.
Here is a ruff sketch what happens once you click activate:
WordPress runs any callback function that is bound with register_activation_hook. Its not required to have an activation hook. If you have a callback function, WordPress runs it, if not, WordPress does not do anything. This callback function is used by plugins to do all sort of stuff like creating default options, creating required database tables, checking for dependent plugins , WordPress and PHP required version compatibility to name a few.
WordPress updates an option in DB to keep track of active plugins. so that these can be loaded for each page call. option id is active_plugins. Screenshot: https://snipboard.io/e7sjB9.jpg
On Next page load, WordPress check this option active_plugins and looks for these active plugins and load/run their header comments file code.
Hope it helps.
Regards,
Rao
P.S. this question belongs to https://wordpress.stackexchange.com/
So say I create some custom fields which can be edited via the front page editor.
I save these changes and want users of my theme to be able to see all of the custom fields I have made as soon as the theme is installed
This way, i can create a theme with pre-defined custom fields all over the website so users who install the theme can edit the custom fields straight away.
Otherwise, all the work done via advanced custom fields is rather pointless as when the theme is packaged, the user won't have access to the database that stores the files. I hope what I am asking makes sense!
EDIT: If this is not possible at all then I would accept that as an answer. If it is not possible then I would need to export then import the database for the made custom fields to display on a client's machine after they install the theme correct?
Totally reasonable question, and something that ACF has thought about and created a guide for. There are basically two parts to this guide, which I'll summarize below:
The actual ACF plugin must be included with your theme, which you can do by either:
Bundling the actual ACF PHP code with your theme (the actual plugin files)
Or, provide a link to the ACF plugin page and prompt users to install the plugin as part of your theme readme.
Including the specific custom fields that go with your theme - this is what your question is mostly asking about. Again, a few different ways to do this:
As a new feature of ACF, you can register custom fields with your theme by using JSON files instead of storing the configuration in the SQL database. This is what I personally use, since it is crazy easy to configure (just create an acf-json folder in the root of your theme) and allows you to use version-control (like GIT) to track custom field changes.
If you prefer the old way, you can register your custom fields in your theme's functions.php file.
Some additional information I can provide:
What about the storage of ACF values, not the configuration?
There is only one "database" for a given Wordpress installation, and the way ACF stores values that users have entered for custom fields with a given post is in the "wp_postmeta" table, by association the value with the post ID, field label (changeable), and field ID (permanent).
This is actually beneficial to you as a theme developer, because it means that if a user does something like installs your theme, enters a bunch of custom field values, accidentally uninstalls your theme or switches to a different one, and then wants to re-enable it, no data is lost.
Ensuring ACF gets installed with your theme
If you choose not to bundle the ACF source with your theme, and instead prompt users to manually install the plugin through the plugin directory, you might want to put some checks into your theme to ensure they do so. You can use something like if(!function_exists('the_field')){ /* Block use of your theme until installed */ } in some strategic spots in your theme code to check if ACF is installed, and if it is not, handle that appropriately and prompt admin to install.
I have been having some hard times trying to configure my website.
I have been looking left and right on the internet for how can i rename certain fields on my webpage. I came to a point were i dint find any more snippets that i can use. If someone is kind enough to hekp me with the snippets for the bellow problems i would be extremly grateful :D
1) Login/ Registration form
i have renamed the Login and regitration form, but i cant rename or completly remove the recover password button ( i tried 4-5 snippetes so far and non worked)
2) On my Account page i did some editing with the gettext snipped, but i wasn't able to translate the following word "Logout" and "edit your password and account details"
3) i don't know how to translate the "search producs", the content of the box
4) i dont know how to rename the "apply coupon" button and the content of the box. For this one i used some snippets, but nothing happened :(
bellow, you can see my website
http://www.toner.eurofinconsulting.ro/wp/
Making adjustments like you have referenced are fairly simple to do in Woocommerce. Having said that, one of the first things to understand is how to correctly make changes to Woo template files. The easiest thing to do is to copy the entire directory /wp-content/plugins/woocommerce/templates to the root of your theme in a directory named YOUR_THEME/woocommerce. This now allows you to adjust any of the templates without touching files in the plugin directory (which you should NEVER do) while retaining the ability to update Woocommerce as updates are available.
Now, to make your changes:
Login/registration form - All changes you need can now be made in wp-content/themes/YOUR_THEME/woocommerce/my-account/form-login.php
Changes for this can be made in wp-content/themes/YOUR_THEME/woocommerce/my-account/my-account.php.
Changes to the search form - If this is using the Woocommerce search form, try making your changes in wp-content/themes/YOUR_THEME/woocommerce/product-searchform.php. If it is not there then try finding the search template used by your Wordpress theme.
When I enable a new menu in Drupal (for example, mymodule), Drupal should be able to get the menu items from mymodule_menu (hook_menu), process the items and insert the menu items to menu_router and menu_links table.
However, my Drupal fails to do so. Each time I enable a module (written by me or modules contributed by others, or core modules), Drupal does not seem to get the new information. The menu items defined in the newly enabled module are not processed and inserted to Drupal's menu system. That means the newly enabled module has no chance to work-- because it's inaccessible.
I did fix this by manually insert the menu item information for the new module into the menu_router and menu_links table and the new menu started working. But this is a nightmare if I have to do this each time I enable a module.
Any one has ever had the same problem? How to fix this?
Thank you in advance.
I would not use any SQL to interact with the menu tables, something nasty could happen if you edit the wrong record.
You must have an error in your hook_menu code. Can you paste it?
Also, if you are developing a module that has menu entries, I find that its handy to call these two functions inside of mymodule_init() when adding/removing links:
cache_clear_all()
menu_router_build()
That will flush all cache and rebuild the menu and anything invoking hook_menu. If it doesn't appear after that, then your code has a bug. I'd like to see it.
You didn't report which Drupal version are you using, but in Drupal 6, the implementations of hook_menu() are not invoked, if not in some occasions (when a module is installed, or when modules updates are executed, in example).
If your module changed the menu callbacks, but it has not an update to execute, you can add an update function containing the following code:
// Change the name of the function to match the module name.
// Change the update number to the correct one for your case.
function custom_module_update_6201() {
if (!variable_get('menu_rebuild_needed', FALSE)) {
variable_set('menu_rebuild_needed', TRUE);
}
}
The variable is checked from index.php, and if its value is TRUE, then Drupal will automatically rebuild the menus.
I am using the Drupal 6 module Content Profile to allow using a CCK defined type as a user profile which is working well. The issue I have is that I want the first completion of the profile to trigger an action however the user may save the profile without completing it. My thoughts on this is to have a checkbox by the save button which states 'My profile is complete' which the user will select once they are happy with it, and I have another module which creates a trigger by using the node_api hook and checking the type of the node, the action, and the value of this checkbox.
Once this trigger has been raised I don't want that checkbox to appear again however. If I could set the visibility of the checkbox using PHP code that would work as I could write a short script to determine if the completed action has already happenede and if so hide the checkbox. Is there a module that allows this? I haven't been able to find one.
I have also looked at using the same node_api hook to manipulate the profile as it is being displayed however the node just seems to have the values for the fields and not a form object that can be manipulated as I would have expected. IS there a way to programatically manipulate a CCK form?
Thanks
I think hook form alter is what you are after. This can perform alterations to a form before it is rendered.
I would suggest another approach using the Save & Edit module. Set your CCK profile type as "unpublished" by default. Allow users to save it and/or save AND publish it with this module. On publish, use triggers and actions.
This approach is arguably more in keeping with the Drupal way - configuration over customization.