Make fonts.com font work in TinyMCE (iframe referrer issue)

I ran into this issue with Typekit, here’s my solution: http://www.tomjn.com/150/typekit-wp-editor-styles/ add_filter(“mce_external_plugins”, “tomjn_mce_external_plugins”); function tomjn_mce_external_plugins($plugin_array){ $plugin_array[‘typekit’] = get_template_directory_uri().’/typekit.tinymce.js’; return $plugin_array; } and this js: (function() { tinymce.create(‘tinymce.plugins.typekit’, { init: function(ed, url) { ed.onPreInit.add(function(ed) { // Get the DOM document object for the IFRAME var doc = ed.getDoc(); // Create the script we will add to … Read more

Renaming a WordPress Admin Menu

This is what I do to rename menu items: in the action hook admin_menu, use a recursive array search to pinpoint the key position of the desired menu and then modify the global $menu array. add_action( ‘admin_menu’, ‘rename_woocoomerce_wpse_100758’, 999 ); function rename_woocoomerce_wpse_100758() { global $menu; // Pinpoint menu item $woo = recursive_array_search_php_91365( ‘WooCommerce’, $menu ); … Read more

Can I force a metabox to be in one column?

If you want the meta box to appear below the content area, use the context parameter ‘normal’. See Function Reference/add meta box – Parameters. Initially, your meta box should only go to the side bar if the context parameter is set to ‘side’. As far as making it impossible for the user to drag it … Read more

How do I set up the defualt page icon for admin menu?

Assuming you’re running WP 3.8, you can choose from a collection of icons (listed here). In your case, replace your icon URL with dashicons-admin-page, like so: add_menu_page( ‘Info’, ‘Info’, ‘manage_options’, ‘LINK’, ”, ‘dashicons-admin-page’, 10 ); You can use these icons in various places around WP. There are various articles on this like this one.

How to remove duplicate sub-menu name for top level menu items in a plugin?

If you dont want ‘TopLevel’ menu to represent a custom page you can use: add_menu_page( ‘TopLevel’, ‘TopLevel’, ‘MENU_CAP_LVL’, ‘MENU_SLUG’, ‘MENU_CB’ ); add_submenu_page( ‘MENU_SLUG’, ‘SubMenu’, ‘SubMenu’, ‘MENU_CAP_LVL’, ‘SUB_MENU_SLUG’, ‘SUB_MENU_CB’ ); add_submenu_page( ‘MENU_SLUG’, ‘SubMenu-A’, ‘SubMenu-A’, ‘MENU_CAP_LVL’, ‘SUB_MENU_A_SLUG’, ‘SUB_MENU_A_CB’ ); remove_submenu_page(‘MENU_SLUG’,’MENU_SLUG’); In this way click on “TopMenu” will forward to the 1st “SubMenu” and prevent “TopLevel” from being … Read more

Stop admin-ajax?

The first thing admin-ajax.php does is define DOING_AJAX. Then, it loads wp-load.php. It does some other stuff, and the first thing it comes across that you have control over is wp-config.php. So if you want to stop all ajax, you can add to following to your wp-config.php file. if( defined( ‘DOING_AJAX’ ) && DOING_AJAX ) … Read more

Restrict Admin Capabilities in MultiSite

Editing super admin capabilities is a little different from editing the capabilities of every other role, because there is a slight detour in the way WP checks the current user’s capabilities. This is what you find on capabilities.php on line 864: function has_cap( $cap ) { // (…) // Multisite super admin has all caps … Read more

Sends out email to admin

No need for plugin here are a few lines of code you can modify and paste in your themes functions.php file and you will get a new email whenever a post is published: add_action(‘publish_post’, ‘send_admin_email’); function send_admin_email($post_id){ $to = ‘[email protected]’; $subject=”mail subject here”; $message = “your message here ex: new post published at: “.get_permalink($post_id); wp_mail($to, … Read more

Filter post listing by meta value which is a date

Add a query variable to store the month So first of all it’ll be necessary to create a custom query variable – this will store the month we’re after (in 2012/6) format. I’ll call it custom_month, but its best practise to prefix it to avoid clashes with other plug-ins: add_filter(‘query_vars’, ‘wpse57344_register_query_vars’ ); function wpse57344_register_query_vars( $qvars … Read more

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