Formatting of curly brackets array from WP database to get more readable output

This is a serialized value, so you should run it through maybe_unserialize() or just unserialize() before you edit it. When you work in plugins or themes, always use the API: update_option() and get_option() for example. These functions will un/serialize the values for you, so you don’t have to worry about the database. See also: Settings … Read more

How to ensure “the_content” filter runs only for the main displayed content?

Try adding a condition to your filtering function that checks your post type against get_post_type. if ( ‘book’ == get_post_type() ) If you wish to apply this filter to pages as well, try is_singular() and include your custom post type(s) as an argument. is_singular(‘book’); This will return true if any of the following conditions are … Read more

WordPress Terminology Options Vs. Settings

These two are pretty close, but relate to slightly different stages of the process. In purely technical terms WordPress has two different APIs — Options API and Settings API. Options API deals with saving and retrieving options from database. So its scope and scope of “options” in terminology is that of purely storage. Settings API … Read more

How to add a link to WordPress Plugin install Listing

This is the filter: “plugin_install_action_links”. You can find this in /wp-admin/includes/class-wp-plugin-install-list-table.php (currently) at line 434: $action_links = apply_filters( ‘plugin_install_action_links’, $action_links, $plugin ); Use it like: add_filter( ‘plugin_install_action_links’, ‘my_custom_links’, 10, 2 ); function my_custom_links( $action_links, $plugin ){ $action_links[] = ‘<a href=””>……</a>’; return $action_links; }

How to Use WordPress Color Picker API in Custom Post Type Metabox

I’ve created a metabox once with color picker. You need to include color picker style and script in your admin_enqueue_scripts hook, and then initialize it with $(‘.color-picker’).wpColorPicker(); From my gist: <?php add_action( ‘admin_enqueue_scripts’, ‘mytheme_backend_scripts’); if ( ! function_exists( ‘mytheme_backend_scripts’ ) ){ function mytheme_backend_scripts($hook) { wp_enqueue_media(); wp_enqueue_style( ‘wp-color-picker’); wp_enqueue_script( ‘wp-color-picker’); } } add_action( ‘add_meta_boxes’, ‘mytheme_add_meta_box’ ); … Read more

Custom Rewriting to Plugin with Parameters

This approach should work for you: <?php /** * Plugin Name: Rewrite Shortcode **/ add_shortcode( ‘myplugin’, ‘mp_shortcode’ ); function mp_shortcode(){ return ‘<p>Filter: ‘ . get_query_var( ‘filter’ ) . ‘</p>’; } add_action( ‘init’, ‘mp_rewrite’ ); function mp_rewrite(){ $post_id = 2; add_rewrite_rule( ‘myplugin/([^/]+)/?$’, ‘index.php?p=’ . $post_id . ‘&filter=$matches[1]’, ‘top’ ); add_rewrite_tag( ‘%filter%’, ‘([^/]+)’ ); } ?> I … Read more

Is it save to require plugin.php early to be able to use get_plugin_data() earlier?

At first glance it works and I cannot see any implications but maybe you are aware of some? You say that you are not getting errors, which I would have expected but it looks as though WordPress uses require_once() so you are probably safe: 39 /** WordPress Plugin Administration API */ 40 require_once(ABSPATH . ‘wp-admin/includes/plugin.php’); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)