WordPress plugin installation

Add this code and replace yourpagename with the your page slug on which u want this filter to execute function my_name( $content ) { global $post; if ( $post->post_name == ‘yourpagename’ ) { return $content; } } add_filter( ‘the_content’, ‘my_name’ );

URL rewriting must be activated manually for my plugin

Whenever I create a plugin that needs permalinks enabled i check on the plugin activation and if its not set i display a message for the user: // Add Check if permalinks are set on plugin activation register_activation_hook( __FILE__, ‘is_permalink_activate’ ); function is_permalink_activate() { //add notice if user needs to enable permalinks if (! get_option(‘permalink_structure’) … Read more

calling jquery function on plugin page

You can review the explanation here to include any script here function my_enqueue($hook) { if( ‘edit.php’ != $hook ) return; wp_enqueue_script( ‘my_custom_script’, plugins_url(‘/myscript.js’, __FILE__) ); } add_action( ‘admin_enqueue_scripts’, ‘my_enqueue’ ); The above code will add the script in all your admin pages. In order to identify the page you may follow this: if (isset($_GET[‘page’]) && … Read more

Determine plugin name from within plugin_action_links filter

There are currently four filters and they carry lots of information: $prefix = $screen->in_admin( ‘network’ ) ? ‘network_admin_’ : ”; $actions = apply_filters( $prefix . ‘plugin_action_links’, array_filter( $actions ), $plugin_file, $plugin_data, $context ); $actions = apply_filters( $prefix . “plugin_action_links_$plugin_file”, $actions, $plugin_file, $plugin_data, $context ); This is a var dump of the parameters for Advanced Custom … Read more

Can I use the different settings sections over different pages using the save options group?

The solution is to merge existing options before saving options in case not all options are presented on the page we are about save. So in the end of $sanitize_callback in register_setting function just before I return the data I call below function where $existing are all existing options saved in database. function merge_options( $existing, … Read more