Customize Menu | Styling LESS/SCSS code formats

I was able to get SASS syntax highlighting in a code textarea in Customizer with the following: add_action( ‘customize_register’, function( WP_Customize_Manager $wp_customize ) { $wp_customize->add_setting( ‘favorite_html’ ); $control = new WP_Customize_Code_Editor_Control( $wp_customize, ‘favorite_html’, array( ‘label’ => ‘SASS’, ‘code_type’ => ‘sass’, ‘settings’ => ‘favorite_html’, ‘section’ => ‘title_tagline’, ) ); $wp_customize->add_control( $control ); } ); via @westonruter … Read more

WordPress Social Sharing Icons – Custom Placement

Here is a quick shortcode for you. You’ll still have to style it the way you want it.Just use:[social-share] to share. // social sharing shortcode, use [social-share] add_shortcode( ‘social-share’, ‘render_social_share’ ); function render_social_share( $atts ){ $social_output=”<p>Share on:</p> <ul> <li><a href=”https://www.facebook.com/sharer/sharer.php?u=” . get_the_permalink() . ‘” target=”_blank”>Facebook</a></li> <li><a href=”https://twitter.com/share?text=” . get_the_title() . “&url=” . get_the_permalink() . “” … Read more

Advanced WordPress plugin activation detection

The init and plugins_loaded hooks are already run before a plugin is activated. That’s why your first code doesn’t work but the second does. Regarding your third code: there’s no need to run add_action(‘myplugin_activate’ … inside init. Not everything needs to be hooked to init. Just use add_action(‘myplugin_activate’, function(){ echo ‘myplugin is not allowed.’; die; … Read more

Insert ads below the title

You can use mh_post_header action hook to add your ads content after the post title. Check the following code snippet for help add_action( ‘mh_post_header’, function() { echo ‘Ads content goes here’; }, 5 );

Translation issue with global variables

Translation works with global variables, you just need to wait until the proper hook to call the translation functions. I haven’t looked at the code or documentation, but just by experimenting, the translations are loaded sometime before the after_setup_theme hook, but after the other hooks that fire before that. That means that if you try … Read more

Change the number of plugins counted on wp-admin/plugins.php

The values haven’t any hook to change this. However it is easy to identify the counter via Javascript. You can change this with short lines of Javascript. Hook You should hook in this page hook of the plugin page admin_footer-plugins.php, like add_action( ‘admin_footer-plugins.php’, [ $this, ‘change_view_values’ ], 11 ); Function include javascript As example a … Read more

How to include files relative to a file’s directory

Plugin within a theme – sounds like something new. You might not find function in this context. Let’s create ours: <?php /** * Get My Plugin URL. * @return string. */ function wpse295740_get_plugin_url() { // http://example.com/wp-content/themes/my-theme/inc/my-plugin return get_template_directory_uri() .’/inc/my-plugin’; } /** * Get My Plugin Path. * @return string. */ function wpse295740_get_plugin_path() { // eg. … Read more