How to properly load text domain of custom mu plugin
How to properly load text domain of custom mu plugin
How to properly load text domain of custom mu plugin
You want to use wp_ajax_nopriv_ for handling ajax for non-authenticated users: // logged-out users add_action( ‘wp_ajax_nopriv_my_action_search_key_press’, ‘action_search_key_press_callback’ ); // authenticated users add_action( ‘wp_ajax_my_action_search_key_press’, ‘action_search_key_press_callback’ );
If you plan to release them independently, then release them independently and try to get them both hosted in the WP repository. This will allow you to update the systems remotely and keep people using the most up-to-date system possible. Then, in your theme, use is_plugin_active() to filter your commands. If you have a theme … Read more
wp_insert_user returns your new user’s ID, if created successful. You can add the user_meta to this ID: $userid = wp_insert_user( $userdata ); if ( !is_wp_error( $userid ) ) { // check if insert was successful add_user_meta( $userid, ‘verification_ref’, $ref ); // add the meta } else { /* Error Handling */ }
Using body_class() on the body tag would probably be the easiest way to tell which template is in use. <body <?php body_class(); ?>> Depending on which page you are on, it will output similar to this <body class=”page page-id-10 page-template-default logged-in”> Where page-template-default is the template in use. It’s also useful for blog posts and … Read more
An Active Plugin To make an active plugin, use the following resources: WordPress Codex: Writing a Plugin WordPress Essentials: How To Create A WordPress Plugin by Daniel Pataki From the following StackExchange thread, try to understand what are the Hooks and what are things acting behind a plugin: How to edit a wordpress plugin without … Read more
Since the plugin author does not offer any actions or filters for us to hook onto, we’ll have to settle for “listening” to changes to the views meta field instead. function wpse_104324_prevent_multiple_views( $meta_id, $object_id, $meta_key, $meta_value ) { if ( $meta_key === ‘views’ ) { if ( ! empty( $_COOKIE[ USER_COOKIE . ‘_views’ ] ) … Read more
Use the upload directory to store files. You should never store files in the plugin directory. There is no guarantee that you have write access there.
You can use wp_nav_menu_{$menu->slug}_items hook and add you link with a callback function, for example if your menu slug is header-menu then something like this: add_filter(‘wp_nav_menu_header-menu_items’, ‘add_my_extra_links’,10,2); function add_my_extra_links($items, $args) { $newitems=”<li><a title=”Test Link” href=”http://google.com”>Google</a></li>”; $newitems .= ‘<li><a title=”Test Link” href=”http://yahoo.com”>Yahoo</a></li>’; $newitems .= ‘<li><a title=”Test Link” href=”http://bing.com”>Bing</a></li>’; $newitems .= $items; return $newitems; } Update I … Read more
Try this: add_menu_page(__(‘My Plugin’, ‘myplugin’),__(‘My Plugin’, ‘myplugin’), ‘edit_posts’,’my-plugin-dashboard’,’my_plugin_dashboard’,’icon’); // dashboard submenu – this fails to highlight with current add_submenu_page(‘my-plugin-dashboard’, __(‘Dashboard’,’myplugin’), __(‘Dashboard’,’myplugin’), ‘edit_posts’, ‘my-plugin-dashboard’, ‘my_plugin_dashboard’ ); // settings submenu – this fails to highlight with current add_submenu_page(‘my-plugin-dashboard’, __(‘Settings’,’myplugin’), __(‘Settings’,’myplugin’), ‘manage_options’, ‘my-plugin-settings’, ‘my_plugin_settings’ ); Essentially: don’t use full page links with admin.php?… as the page slug. Especially … Read more