WordPress.org

Ready to get started?Download WordPress

Ideas

Update WP_Internal_Pointers::print_js from Private to Public

  1. nic0tin
    Member

    Hello,

    Today I wanted to use WP_Internal_Pointers in the public side of my intranet blog based on WP 3.5, but I had to change the core file "wp-admin/includes/template.php" for the static function "print_js" from private to public.

    I did so for running this code (themes/theme_name/functions.php):

    function gp_reveal_pointers()
    {
    	global $wp_scripts;
    
    	$wp_scripts->localize( 'wp-pointer', 'wpPointerL10n', array(
    			'dismiss' => __('Dismiss'),
    		) ); // Retrieve Dismiss translated text
    	$dismissed = array_filter( explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ) );
    
    	if ( in_array( 'gp110_revues', $dismissed ) ) // Already dismissed? Nothing to display.
    		return;
    
    	if(!class_exists("WP_Internal_Pointers"))
    		include(ABSPATH ."/wp-admin/includes/template.php");
    	$content = '<h3>My title</h3>'
    			  .'<p>My content.</p>';
    	$position = array( 'edge' => 'bottom', 'align' => 'center' );
    	WP_Internal_Pointers::print_js('gp110_revues', '.widget-revues', array('content' => $content, 'position' => $position));
    ?>
    <script type="text/javascript">
    /* <![CDATA[ */
    var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
    /* ]]> */
    </script>
    <?php
    }
    add_action('get_footer', 'gp_reveal_pointers');

    I thought it would be a good thing to change the print_js function from private to public unless off course it's considered as too critical to be publicly exposed.

    Posted: 1 year ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    1 Vote
  • Status

    This idea is under consideration