Ninja Pumpkin Mutants

    cp-page-tools

    1.0.1 • Public • Published

    Content Pilot Page Tools

    Set of page tools for users to print, email, share, etc.

    Install as devDependency

    npm install cp-page-tools --save-dev

    Require JS file in task runner

    ./node_modules/cp-page-tools/cp-page-tools.js

    Bind to content area

    $('.page-header').cpPageTools();

    PHP markup

    function poa_page_tools() {
    	// Guard to only show on single pages
    	if( !is_single() || !is_singular() ) {
    		return;
    	}
    	$tools = array(
    		'pdf' => array(
    			'type' 	=> 'url',
    			'check' => class_exists('P2p'),
    			'url' 	=> get_permalink() . 'pdf',
    			'title' => 'PDF',
    			'order' => 5
    		),
    		'print' => array(
    			'type' 	=> 'url',
    			'check' => true,
    			'url' 	=> add_query_arg( 'print', 'true', get_permalink() ),
    			'title' => 'Print',
    			'order' => 10
    		),		
    		'email' => array(
    			'type' 	=> 'url',
    			'check' => true,
    			'url' 	=> '#',
    			'title' => 'Share',
    			'order' => 15
    		),		
    		'share' => array(
    			'type' 	=> 'shortcode',
    			'check' => function_exists('A2A_SHARE_SAVE_shortcode'),
    			'url' 	=> '[addtoany]',
    			'title' => 'Social',
    			'order' => 20
    		),
    	);
    	echo '<div class="page-tools">';
    	foreach ($tools as $tool) {
    		if( $tool['check'] && ('url' == $tool['type']) ) {
    			printf('<a href="%s" class="tool tool-%s" rel="nofollow">%s</a>', 
    				esc_url($tool['url']),
    				esc_attr(strtolower($tool['title'])),
    				esc_html__($tool['title'], 'fross-zelnick')
    			);
    		}elseif( $tool['check'] && ('shortcode' == $tool['type']) ) {
    			echo do_shortcode($tool['url']);
    		}
    	}
    	echo '</div>';
    }

    Change Log

    = 1.0.1 = 6/5/2018

    • Fix formatting in Readme.md

    = 1.0.0 = 6/5/2018

    • Initial commit

    Install

    npm i cp-page-tools

    DownloadsWeekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    3.37 kB

    Total Files

    3

    Last publish

    Collaborators

    • dushakov92
    • claytoncollie
    • fh_cp
    • greggc