Ejemplo n.º 1
0
function nks_cc_display_str($args)
{
    $options = nks_cc_get_options();
    $index = $args["index"];
    $user_opts = json_decode($options['nks_cc_display_' . $index]);
    $locations = nks_get_locations();
    //browser()->log('tab ' .$index . ' opts');
    //browser()->log($user_opts);
    ?>
	<p>
		<input id='nks_cc_display_<?php 
    echo $index;
    ?>
' name='nks_cc_options[nks_cc_display_<?php 
    echo $index;
    ?>
]' type='hidden' value='<?php 
    echo $options['nks_cc_display_' . $index];
    ?>
' />
		<a class='nks_location' href='#'><i class='fa fa-cog'></i> <span>Tab Display Options</span></a>
	<div class='loc_popup'>
		<p>
			<label for="nks_cc_user_status_<?php 
    echo $index;
    ?>
"><?php 
    _e('Show Tab for:', 'nks-custom');
    ?>
</label>
			<select name="display_user_status_<?php 
    echo $index;
    ?>
" id="nks_cc_user_status_<?php 
    echo $index;
    ?>
" class="widefat">
				<option value="everyone" <?php 
    echo selected($user_opts->user->everyone, '1');
    ?>
><?php 
    _e('Everyone', 'nks-custom');
    ?>
</option>
				<option value="loggedout" <?php 
    echo selected($user_opts->user->loggedout, '1');
    ?>
><?php 
    _e('Logged-out users', 'nks-custom');
    ?>
</option>
				<option value="loggedin" <?php 
    echo selected($user_opts->user->loggedin, '1');
    ?>
><?php 
    _e('Logged-in users', 'nks-custom');
    ?>
</option>
			</select>
		</p>

		<p>
			<label for="nks_cc_display_mobile_<?php 
    echo $index;
    ?>
"><?php 
    _e('Show on mobiles:', 'nks-custom');
    ?>
</label>
			<select name="display_mobile_<?php 
    echo $index;
    ?>
" id="nks_cc_display_mobile_<?php 
    echo $index;
    ?>
" class="widefat">
				<option value="yes" <?php 
    echo selected($user_opts->mobile->yes, '1');
    ?>
><?php 
    _e('Show', 'nks-custom');
    ?>
</option>
				<option value="no" <?php 
    echo selected($user_opts->mobile->no, '1');
    ?>
><?php 
    _e('Don\'t show', 'nks-custom');
    ?>
</option>
			</select>
		</p>

		<p>
			<label for="nks_cc_user_status_<?php 
    echo $index;
    ?>
"><?php 
    _e('Display rule:', 'nks-custom');
    ?>
</label>

			<select name="display_rule_<?php 
    echo $index;
    ?>
" id="display_rule_<?php 
    echo $index;
    ?>
" class="widefat">
				<option value="exclude" <?php 
    echo selected($user_opts->rule->exclude, '1');
    ?>
><?php 
    _e('Hide on checked pages', 'nks-custom');
    ?>
</option>
				<option value="include" <?php 
    echo selected($user_opts->rule->include, '1');
    ?>
><?php 
    _e('Show on checked pages', 'nks-custom');
    ?>
</option>
			</select>
		</p>

		<div style="height:150px; overflow:auto; border:1px solid #dfdfdf; padding:5px; margin-bottom:5px;">
			<h4 class="dw_toggle" style="cursor:pointer;margin-top:0;"><?php 
    _e('Default WP pages', 'nks-custom');
    ?>
</h4>
			<div class="dw_collapse">
				<?php 
    foreach ($locations->wp_pages as $key => $label) {
        ?>
					<p><input class="checkbox" type="checkbox" value="<?php 
        echo $key;
        ?>
" <?php 
        checked(isset($user_opts->location->wp_pages->{$key}) ? $user_opts->location->wp_pages->{$key} : false, true);
        ?>
 id="display_wp_page_<?php 
        echo $key . '_' . $index;
        ?>
" name="display_wp_page_<?php 
        echo $key . '_' . $index;
        ?>
" />
						<label for="display_wp_page_<?php 
        echo $key . '_' . $index;
        ?>
"><?php 
        echo $label . ' ' . __('Page', 'nks-custom');
        ?>
</label></p>
				<?php 
    }
    ?>
			</div>

			<h4 class="dw_toggle" style="cursor:pointer;"><?php 
    _e('Pages');
    ?>
</h4>
			<div class="dw_collapse">
				<?php 
    foreach ($locations->pages as $page) {
        //$instance['page-'. $page->ID] = isset($instance['page-'. $page->ID]) ? $instance['page-'. $page->ID] : false;
        $id = $page->ID;
        $p_title = apply_filters('the_title', $page->post_title, $page->ID);
        if ($page->post_parent) {
            $parent = get_post($page->post_parent);
            $p_title .= ' (' . apply_filters('the_title', $parent->post_title, $parent->ID);
            if ($parent->post_parent) {
                $grandparent = get_post($parent->post_parent);
                $p_title .= ' - ' . apply_filters('the_title', $grandparent->post_title, $grandparent->ID);
                unset($grandparent);
            }
            $p_title .= ')';
            unset($parent);
        }
        //browser()->log($p_title);
        ?>
					<p><input class="checkbox" type="checkbox" value="<?php 
        echo $id;
        ?>
" <?php 
        checked(isset($user_opts->location->pages->{$id}), true);
        ?>
 id="display_page_<?php 
        echo $id . '_' . $index;
        ?>
" name="display_page_<?php 
        echo $id . '_' . $index;
        ?>
" />
						<label for="display_page_<?php 
        echo $id . '_' . $index;
        ?>
"><?php 
        echo $p_title;
        ?>
</label></p>
					<?php 
        unset($p_title);
    }
    ?>
			</div>

			<?php 
    if (!empty($locations->cposts)) {
        ?>
				<h4 class="dw_toggle" style="cursor:pointer;"><?php 
        _e('Custom Post Types', 'nks-custom');
        ?>
 +/-</h4>
				<div class="dw_collapse">
					<?php 
        foreach ($locations->cposts as $post_key => $custom_post) {
            ?>
						<p><input class="checkbox" type="checkbox" value="<?php 
            echo $post_key;
            ?>
" <?php 
            checked(isset($user_opts->location->cposts->{$post_key}), true);
            ?>
 id="display_cpost_<?php 
            echo $post_key . '_' . $index;
            ?>
" name="display_cpost_<?php 
            echo $post_key . '_' . $index;
            ?>
" />
							<label for="display_cpost_<?php 
            echo $post_key . '_' . $index;
            ?>
"><?php 
            echo stripslashes($custom_post->labels->name);
            ?>
</label></p>
						<?php 
            unset($post_key);
            unset($custom_post);
        }
        ?>
				</div>

				<!--<h4 class="dw_toggle" style="cursor:pointer;"><?php 
        /*_e('Custom Post Type Archives', 'nks-custom') */
        ?>
 +/-</h4>
				<div class="dw_collapse">
					<?php 
        /*foreach ( $this->cposts as $post_key => $custom_post ) {
        		if ( !$custom_post->has_archive ) {
        			// don't give the option if there is no archive page
        			continue;
        		}
        		$instance['type-'. $post_key .'-archive'] = isset($instance['type-'. $post_key .'-archive']) ? $instance['type-'. $post_key .'-archive'] : false;
        		*/
        ?>
						<p><input class="checkbox" type="checkbox" <?php 
        /*checked($instance['type-'. $post_key.'-archive'], true) */
        ?>
 id="<?php 
        /*echo $widget->get_field_id('type-'. $post_key .'-archive'); */
        ?>
" name="<?php 
        /*echo $widget->get_field_name('type-'. $post_key .'-archive'); */
        ?>
" />
							<label for="<?php 
        /*echo $widget->get_field_id('type-'. $post_key .'-archive'); */
        ?>
"><?php 
        /*echo stripslashes($custom_post->labels->name) */
        ?>
 <?php 
        /*_e('Archive', 'nks-custom') */
        ?>
</label></p>
					<?php 
        /*} */
        ?>
				</div>-->
			<?php 
    }
    ?>

			<h4 class="dw_toggle" style="cursor:pointer;"><?php 
    _e('Categories');
    ?>
</h4>
			<div class="dw_collapse">
				<?php 
    foreach ($locations->cats as $cat) {
        $catid = $cat->cat_ID;
        ?>
					<p><input class="checkbox" type="checkbox"  value="<?php 
        echo $catid;
        ?>
" <?php 
        checked(isset($user_opts->location->cats->{$catid}), true);
        ?>
 id="display_cat_<?php 
        echo $catid . '_' . $index;
        ?>
" name="display_cat_<?php 
        echo $catid . '_' . $index;
        ?>
" />
						<label for="display_cat_<?php 
        echo $catid . '_' . $index;
        ?>
"><?php 
        echo $cat->cat_name;
        ?>
</label></p>
					<?php 
        unset($cat);
    }
    ?>
			</div>

			<?php 
    /*if ( !empty($this->taxes) ) { */
    ?>
<!--
				<h4 class="dw_toggle" style="cursor:pointer;"><?php 
    /*_e('Taxonomies', 'nks-custom') */
    ?>
 +/-</h4>
				<div class="dw_collapse">
					<?php 
    /*foreach ( $this->taxes as $tax ) {
    		$instance['tax-'. $tax] = isset($instance['tax-'. $tax]) ? $instance['tax-'. $tax] : false;
    		*/
    ?>
						<p><input class="checkbox" type="checkbox" <?php 
    /*checked($instance['tax-'. $tax], true) */
    ?>
 id="<?php 
    /*echo $widget->get_field_id('tax-'. $tax); */
    ?>
" name="<?php 
    /*echo $widget->get_field_name('tax-'. $tax); */
    ?>
" />
							<label for="<?php 
    /*echo $widget->get_field_id('tax-'. $tax); */
    ?>
"><?php 
    /*echo str_replace(array('_','-'), ' ', ucfirst($tax)) */
    ?>
</label></p>
						<?php 
    /*						unset($tax);
    					}
    					*/
    ?>
				</div>
			--><?php 
    /*} */
    ?>

			<?php 
    if (!empty($locations->langs)) {
        ?>
				<h4 class="dw_toggle" style="cursor:pointer;"><?php 
        _e('Languages', 'nks-custom');
        ?>
</h4>
				<div class="dw_collapse">
					<?php 
        foreach ($locations->langs as $lang) {
            $key = $lang['language_code'];
            ?>
						<p><input class="checkbox" type="checkbox" <?php 
            checked(isset($user_opts->location->langs->{$key}), true);
            ?>
 id="display_lang_<?php 
            echo $key . '_' . $index;
            ?>
" name="display_lang_<?php 
            echo $key . '_' . $index;
            ?>
" />
							<label for="display_lang_<?php 
            echo $key . '_' . $index;
            ?>
"><?php 
            echo $lang['native_name'];
            ?>
</label></p>

						<?php 
            unset($lang);
            unset($key);
        }
        ?>
				</div>
			<?php 
    }
    ?>

			<p><label for="display_ids_<?php 
    echo $index;
    ?>
"><?php 
    _e('Comma Separated list of IDs of posts not listed above', 'nks-custom');
    ?>
:</label>
				<input type="text" value="<?php 
    echo implode(",", $user_opts->location->ids);
    ?>
" name="display_ids_<?php 
    echo $index;
    ?>
" id="display_ids_<?php 
    echo $index;
    ?>
" />
			</p>
		</div>

		<a class="close_pop" href="#">Close</a>
		<button name='Submit' type='submit' id='sbmt_nks_cc_popup_<?php 
    echo $index;
    ?>
' class='display-sbmt button-primary' value='Save'>Save Options For&nbsp;&nbsp;<i class='fa <?php 
    echo $options['nks_cc_fa_icon_' . $index];
    ?>
'></i></button>

	</div>
	</p>
<?php 
}
Ejemplo n.º 2
0
function register_nks_widget_area()
{
    $options = nks_cc_get_options();
    if (function_exists('register_sidebar')) {
        for ($i = 1; $i <= $options['nks_cc_tabs']; $i++) {
            register_sidebar(array('name' => 'Ninja Kick Tab ' . $i, 'id' => 'nks_area_' . $i, 'description' => __('Widgets in this area will be shown in Ninja Kick Panel', 'nks-custom'), 'before_widget' => '<div class="widget">', 'after_widget' => '</div>', 'before_title' => '<h1 class="title">', 'after_title' => '</h1>'));
        }
    }
}