How do you store options with a:n:{{}} syntax in wp_options?
Just pass an array when updating your option. It will be serialized automatically.
Just pass an array when updating your option. It will be serialized automatically.
Turns out I solved my own question with help from a colleague. The two filters that get called after media is uploaded or when media is being edited are; ‘add_attachment’ and ‘edit_attachment’. Here is the code I am using, I then check to see if the attachment is an image (code omitted from example). function … Read more
Set the parent_slug property to null, example; add_submenu_page( null // -> Set to null – will hide menu link , ‘Page Title’ // -> Page Title , ‘Menu Title’ // -> Title that would otherwise appear in the menu , ‘administrator’ // -> Capability level , ‘menu_handle’ // -> Still accessible via admin.php?page=menu_handle , ‘page_callback’ … Read more
get_posts passes the heavy lifting off to WP_Query and if you look at the source of that class you can see that there are only a limited number of options with that fields argument. There are only three options in that switch— ids, id=>parent, and the default case, everything. You can use the posts_fields filter … Read more
If the plugin structure is: plugins/ some-plugin/ some-plugin.php data/ GeoIP.dat then for PHP 5.3.0+, you could try the magic constant __DIR__ __DIR__ The directory of the file. If used inside an include, the directory of the included file is returned. This is equivalent to dirname(__FILE__). This directory name does not have a trailing slash unless … Read more
The print_r function accept second parameter for return so it retrun the variable instead of printing it. print_r($expression, $return) So you can do error_log( print_r( $variable, true ) );
You have to do: add_action( ‘init’, ‘custom_taxonomy_Item’ ); Because: Use the init action to call this function. Calling it outside of an action can lead to troubles. see codex page register_taxonomy. Besides that : Better be safe than sorry when registering custom taxonomies for custom post types. Use register_taxonomy_for_object_type() right after the function to interconnect … Read more
The answers here are overthought and too complex. Why deactivating the plugin instead of preventing activation? Something as simple as calling die(‘your error message here) upon activation will do the job. function activate($networkwide) { if (is_multisite() && $networkwide) die(‘This plugin can\’t be activated networkwide’); } register_activation_hook(‘your-plugin/index.php’,’activate’); Then when you try to activate in the panel, … Read more
admin_url() gets you the correct administration page URL (and network_admin_url() to get a network administration page URL) Optionally, you can use add_query_arg() to append arguments to an URL, using an associative array: $page=”edit_record_page”; $rec_id = 1; $record_url = add_query_arg(compact(‘page’, ‘rec_id’), admin_url(‘admin.php’));
These two functions accomplish two different things. wp_footer() is a hook used in your footer.php template file to ensure that the right code is inserted (from the core/plugins/etc) into the right place. get_footer() is used in your other template files to call for the code in your footer.php template file. So in simpler words wp_footer() … Read more