Exemplo n.º 1
0
    private static function get_home_box_tpl($placeholder = '%placeholder%', array $boxes = [])
    {
        $title = isset($boxes[$placeholder]['title']) ? stripcslashes($boxes[$placeholder]['title']) : null;
        if ($placeholder !== '%placeholder%' && !$title) {
            return false;
        }
        $icon = isset($boxes[$placeholder]['icon']) ? $boxes[$placeholder]['icon'] : null;
        $link = isset($boxes[$placeholder]['link']) ? $boxes[$placeholder]['link'] : null;
        $number = isset($boxes[$placeholder]['number']) ? (int) $boxes[$placeholder]['number'] : 7;
        $display = isset($boxes[$placeholder]['display-type']) ? $boxes[$placeholder]['display-type'] : 'all';
        $keywords = isset($boxes[$placeholder]['keywords']) ? $boxes[$placeholder]['keywords'] : null;
        $ad = isset($boxes[$placeholder]['ad']) ? stripslashes($boxes[$placeholder]['ad']) : null;
        ob_start();
        ?>
		<table 
			class="form-table <?php 
        echo __CLASS__;
        ?>
-item item tpl-item" 
			id="<?php 
        echo __CLASS__;
        ?>
-item-<?php 
        echo $placeholder;
        ?>
" 
			data-placeholder="<?php 
        echo $placeholder;
        ?>
" 
		>
		<tbody>
		<tr>
			<th><label for="<?php 
        echo __CLASS__;
        ?>
-title-<?php 
        echo $placeholder;
        ?>
"><?php 
        echo ___('Title');
        ?>
 - <?php 
        echo $placeholder;
        ?>
</label></th>
			<td>
				<input 
					type="text" 
					name="<?php 
        echo __CLASS__;
        ?>
[<?php 
        echo $placeholder;
        ?>
][title]" 
					id="<?php 
        echo __CLASS__;
        ?>
-title-<?php 
        echo $placeholder;
        ?>
" 
					class="widefat" 
					value="<?php 
        echo esc_attr($title);
        ?>
" 
					placeholder="<?php 
        echo ___('Box title');
        ?>
"
				> 
			</td>
		</tr>
		<tr>
			<th>
				<label for="<?php 
        echo __CLASS__;
        ?>
-icon-<?php 
        echo $placeholder;
        ?>
"><?php 
        echo ___('Icon');
        ?>
</label>
				<a href="//fortawesome.github.io/Font-Awesome/icons" target="_blank" title="<?php 
        echo ___('Views all icons');
        ?>
">#<?php 
        echo ___('ALL');
        ?>
</a>
			</th>
			<td>
				<input 
					type="text" 
					value="<?php 
        echo $icon;
        ?>
" 
					list="<?php 
        echo __CLASS__;
        ?>
-icon-<?php 
        echo $placeholder;
        ?>
-datalist" 
					name="<?php 
        echo __CLASS__;
        ?>
[<?php 
        echo $placeholder;
        ?>
][icon]" 
					id="<?php 
        echo __CLASS__;
        ?>
-icon-<?php 
        echo $placeholder;
        ?>
" 
					class="widefat" 
				><?php 
        icon_option_list(__CLASS__ . '-icon-' . $placeholder . '-datalist');
        ?>
			</td>
		</tr>
		<tr>
			<th><label for="<?php 
        echo __CLASS__;
        ?>
-link-<?php 
        echo $placeholder;
        ?>
"><?php 
        echo ___('Link');
        ?>
</label></th>
			<td>
				<input 
					type="url" 
					name="<?php 
        echo __CLASS__;
        ?>
[<?php 
        echo $placeholder;
        ?>
][link]" 
					id="<?php 
        echo __CLASS__;
        ?>
-link-<?php 
        echo $placeholder;
        ?>
" 
					class="widefat" 
					value="<?php 
        echo esc_attr($link);
        ?>
" 
					placeholder="<?php 
        echo ___('Box link (include http://)');
        ?>
"
				>
			</td>
		</tr>
		<tr>
			<th><label for="<?php 
        echo __CLASS__;
        ?>
-number-<?php 
        echo $placeholder;
        ?>
"><?php 
        echo ___('Show posts');
        ?>
</label></th>
			<td>
				<input 
					type="number" 
					name="<?php 
        echo __CLASS__;
        ?>
[<?php 
        echo $placeholder;
        ?>
][number]" 
					id="<?php 
        echo __CLASS__;
        ?>
-number-<?php 
        echo $placeholder;
        ?>
" 
					class="small-text" 
					value="<?php 
        echo $number;
        ?>
" 
					placeholder="<?php 
        echo ___('Posts number.');
        ?>
" 
					min="3" 
					step="4" 
				>
			</td>
		</tr>
		<tr>
			<th><label for="<?php 
        echo __CLASS__;
        ?>
-display-type-<?php 
        echo $placeholder;
        ?>
"><?php 
        echo ___('Display type');
        ?>
</label></th>
			<td>
				<select  
					name="<?php 
        echo __CLASS__;
        ?>
[<?php 
        echo $placeholder;
        ?>
][display-type]" 
					id="<?php 
        echo __CLASS__;
        ?>
-display-type-<?php 
        echo $placeholder;
        ?>
" 
					class="widefat" 
				>
					<?php 
        the_option_list('all', ___('All'), $display);
        ?>
					<?php 
        the_option_list('login', ___('Only login'), $display);
        ?>
					<?php 
        the_option_list('logout', ___('Only logout'), $display);
        ?>
				</select>
			</td>
		</tr>
		
		<tr>
			<th><?php 
        echo ___('Categories');
        ?>
</th>
			<td>
				<?php 
        self::cat_checkbox_tpl($placeholder);
        ?>
			</td>
		</tr>
		<tr>
			<th><label for="<?php 
        echo __CLASS__;
        ?>
-<?php 
        echo $placeholder;
        ?>
-keywords"><?php 
        echo ___('Keywords and links');
        ?>
</label></th>
			<td>
				<textarea name="<?php 
        echo __CLASS__;
        ?>
[<?php 
        echo $placeholder;
        ?>
][keywords]" id="<?php 
        echo __CLASS__;
        ?>
-<?php 
        echo $placeholder;
        ?>
-keywords" cols="30" rows="5" class="widefat" placeholder="<?php 
        echo ___('Eg. Tag1 = http://inn-studio.com');
        ?>
"><?php 
        echo esc_textarea($keywords);
        ?>
</textarea>
				<span class="description"><?php 
        echo ___('Per keyword/line');
        ?>
</span>
			</td>
		</tr>
		<tr>
			<th><label for="<?php 
        echo __CLASS__;
        ?>
-<?php 
        echo $placeholder;
        ?>
-ad"><?php 
        echo ___('AD code');
        ?>
</label></th>
			<td>
				<textarea name="<?php 
        echo __CLASS__;
        ?>
[<?php 
        echo $placeholder;
        ?>
][ad]" id="<?php 
        echo __CLASS__;
        ?>
-<?php 
        echo $placeholder;
        ?>
-ad" cols="30" rows="5" class="widefat" placeholder="<?php 
        echo ___('HTML code will display below this box.');
        ?>
"><?php 
        echo $ad;
        ?>
</textarea>
			</td>
		</tr>
		<tr>
			<th><?php 
        echo ___('Control');
        ?>
</th>
			<td>
				<a href="javascript:;" class="del" data-target="<?php 
        echo __CLASS__;
        ?>
-item-<?php 
        echo $placeholder;
        ?>
"><i class="fa fa-exclamation-circle"></i> <?php 
        echo ___('Delete this item');
        ?>
</a>
			</td>
		</tr>
		</tbody>
		</table>
		<?php 
        $content = ob_get_contents();
        ob_end_clean();
        return $content;
    }
Exemplo n.º 2
0
    public static function display_backend()
    {
        $recomm_posts = self::get_ids();
        ?>
		<fieldset>
			<legend><i class="fa fa-fw fa-thumbs-o-up"></i> <?php 
        echo ___('Recommended posts');
        ?>
</legend>
			<p><?php 
        echo ___('Recommended posts will display on home page if enabled.');
        ?>
</p>
			<table class="form-table">
				<tbody>
					<tr>
						<th><label for="<?php 
        echo __CLASS__;
        ?>
-enabled"></label><?php 
        echo ___('Enable or not?');
        ?>
</th>
						<td>
							<select name="<?php 
        echo __CLASS__;
        ?>
[enabled]" id="<?php 
        echo __CLASS__;
        ?>
-enabled" class="widefat">
								<?php 
        the_option_list(-1, ___('Disable'), self::get_options('enabled'));
        ?>
								<?php 
        the_option_list(1, ___('Enable'), self::get_options('enabled'));
        ?>
							</select>
						</td>
					</tr>
					<tr>
						<th><label for="<?php 
        echo __CLASS__;
        ?>
-title"></label><?php 
        echo ___('Box title');
        ?>
</th>
						<td>
							<input type="text" name="<?php 
        echo __CLASS__;
        ?>
[title]" id="<?php 
        echo __CLASS__;
        ?>
-title" value="<?php 
        echo self::get_item('title');
        ?>
" class="widefat">
						</td>
					</tr>
					<tr>
						<th>
							<label for="<?php 
        echo __CLASS__;
        ?>
-icon"><?php 
        echo ___('Box icon');
        ?>
</label>
							<a href="//fortawesome.github.io/Font-Awesome/icons" target="_blank" title="<?php 
        echo ___('Views all icons');
        ?>
">#<?php 
        echo ___('ALL');
        ?>
</a>
						</th>
						<td>
							<input 
								type="text" 
								value="<?php 
        echo self::get_item('icon');
        ?>
" 
								list="<?php 
        echo __CLASS__;
        ?>
-icon-datalist" 
								name="<?php 
        echo __CLASS__;
        ?>
[icon]" 
								id="<?php 
        echo __CLASS__;
        ?>
-icon" 
								class="widefat" 
							><?php 
        icon_option_list(__CLASS__ . '-icon-datalist');
        ?>
						</td>
					</tr>
					<tr>
						<th><label for="<?php 
        echo __CLASS__;
        ?>
-number"></label><?php 
        echo ___('Show posts number');
        ?>
</th>
						<td>
							<input type="number" name="<?php 
        echo __CLASS__;
        ?>
[number]" id="<?php 
        echo __CLASS__;
        ?>
-number" min="4" step="4" value="<?php 
        echo self::get_item('number');
        ?>
" class="short-text">
						</td>
					</tr>
					<tr>
						<th scope="row"><?php 
        echo ___('Marked posts');
        ?>
</th>
						<td>
							<?php 
        if (!empty($recomm_posts)) {
            global $post;
            $query = new WP_Query(['posts_per_page' => -1, 'post__in' => $recomm_posts, 'ignore_sticky_posts' => true]);
            if ($query->have_posts()) {
                foreach ($query->posts as $post) {
                    setup_postdata($post);
                    ?>
<label for="<?php 
                    echo __CLASS__;
                    ?>
-<?php 
                    echo $post->ID;
                    ?>
" class="button">
	<input type="checkbox" id="<?php 
                    echo __CLASS__;
                    ?>
-<?php 
                    echo $post->ID;
                    ?>
" name="<?php 
                    echo __CLASS__;
                    ?>
[ids][]" value="<?php 
                    echo $post->ID;
                    ?>
" checked >
	#<?php 
                    echo $post->ID;
                    ?>
 <?php 
                    echo theme_cache::get_the_title($post->ID);
                    ?>
 
	<a href="<?php 
                    echo esc_url(get_edit_post_link($post->ID));
                    ?>
" target="_blank" title="<?php 
                    echo ___('Open in open window');
                    ?>
"><i class="fa fa-external-link"></i></a>
</label>
										<?php 
                }
                wp_reset_postdata();
            } else {
                echo status_tip('info', ___('No any post yet'));
            }
        } else {
            echo status_tip('info', ___('No any post yet'));
        }
        ?>
						</td>
					</tr>
				</tbody>
			</table>
		</fieldset>
		<?php 
    }
    /**
     * Start the element output.
     *
     * @see Walker_Nav_Menu::start_el()
     * @since 3.0.0
     *
     * @param string $output Passed by reference. Used to append additional content.
     * @param object $item   Menu item data object.
     * @param int    $depth  Depth of menu item. Used for padding.
     * @param array  $args   Not used.
     * @param int    $id     Not used.
     */
    public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0)
    {
        global $_wp_nav_menu_max_depth;
        $_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
        ob_start();
        $item_id = esc_attr($item->ID);
        $removed_args = array('action', 'customlink-tab', 'edit-menu-item', 'menu-item', 'page-tab', '_wpnonce');
        $original_title = '';
        if ('taxonomy' == $item->type) {
            $original_title = get_term_field('name', $item->object_id, $item->object, 'raw');
            if (is_wp_error($original_title)) {
                $original_title = false;
            }
        } elseif ('post_type' == $item->type) {
            $original_object = theme_cache::get_post($item->object_id);
            $original_title = theme_cache::get_the_title($original_object->ID);
        }
        $classes = array('menu-item menu-item-depth-' . $depth, 'menu-item-' . esc_attr($item->object), 'menu-item-edit-' . (isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] ? 'active' : 'inactive'));
        $title = $item->title;
        if (!empty($item->_invalid)) {
            $classes[] = 'menu-item-invalid';
            /* translators: %s: title of menu item which is invalid */
            $title = sprintf(__('%s (Invalid)'), $item->title);
        } elseif (isset($item->post_status) && 'draft' == $item->post_status) {
            $classes[] = 'pending';
            /* translators: %s: title of menu item in draft status */
            $title = sprintf(__('%s (Pending)'), $item->title);
        }
        $title = !isset($item->label) || '' == $item->label ? $title : $item->label;
        $submenu_text = '';
        if (0 == $depth) {
            $submenu_text = 'style="display: none;"';
        }
        ?>
		<li id="menu-item-<?php 
        echo $item_id;
        ?>
" class="<?php 
        echo implode(' ', $classes);
        ?>
">
			<dl class="menu-item-bar">
				<dt class="menu-item-handle">
					<span class="item-title"><span class="menu-item-title"><?php 
        echo esc_html($title);
        ?>
</span> <span class="is-submenu" <?php 
        echo $submenu_text;
        ?>
><?php 
        _e('sub item');
        ?>
</span></span>
					<span class="item-controls">
						<span class="item-type"><?php 
        echo esc_html($item->type_label);
        ?>
</span>
						<span class="item-order hide-if-js">
							<a href="<?php 
        echo wp_nonce_url(add_query_arg(array('action' => 'move-up-menu-item', 'menu-item' => $item_id), remove_query_arg($removed_args, admin_url('nav-menus.php'))), 'move-menu_item');
        ?>
" class="item-move-up"><abbr title="<?php 
        esc_attr_e('Move up');
        ?>
">&#8593;</abbr></a>
							|
							<a href="<?php 
        echo wp_nonce_url(add_query_arg(array('action' => 'move-down-menu-item', 'menu-item' => $item_id), remove_query_arg($removed_args, admin_url('nav-menus.php'))), 'move-menu_item');
        ?>
" class="item-move-down"><abbr title="<?php 
        esc_attr_e('Move down');
        ?>
">&#8595;</abbr></a>
						</span>
						<a class="item-edit" id="edit-<?php 
        echo $item_id;
        ?>
" title="<?php 
        esc_attr_e('Edit Menu Item');
        ?>
" href="<?php 
        echo isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] ? admin_url('nav-menus.php') : add_query_arg('edit-menu-item', $item_id, remove_query_arg($removed_args, admin_url('nav-menus.php#menu-item-settings-' . $item_id)));
        ?>
"><?php 
        _e('Edit Menu Item');
        ?>
</a>
					</span>
				</dt>
			</dl>

			<div class="menu-item-settings" id="menu-item-settings-<?php 
        echo $item_id;
        ?>
">
				<?php 
        if ('custom' == $item->type) {
            ?>
					<p class="field-url description description-wide">
						<label for="edit-menu-item-url-<?php 
            echo $item_id;
            ?>
">
							<?php 
            _e('URL');
            ?>
<br />
							<input type="text" id="edit-menu-item-url-<?php 
            echo $item_id;
            ?>
" class="widefat code edit-menu-item-url" name="menu-item-url[<?php 
            echo $item_id;
            ?>
]" value="<?php 
            echo esc_attr($item->url);
            ?>
" />
						</label>
					</p>
				<?php 
        }
        ?>
				<p class="description description-thin">
					<label for="edit-menu-item-title-<?php 
        echo $item_id;
        ?>
">
						<?php 
        _e('Navigation Label');
        ?>
<br />
						<input type="text" id="edit-menu-item-title-<?php 
        echo $item_id;
        ?>
" class="widefat edit-menu-item-title" name="menu-item-title[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->title);
        ?>
" />
					</label>
				</p>
				<p class="description description-thin">
					<label for="edit-menu-item-attr-title-<?php 
        echo $item_id;
        ?>
">
						<?php 
        _e('Title Attribute');
        ?>
<br />
						<input type="text" id="edit-menu-item-attr-title-<?php 
        echo $item_id;
        ?>
" class="widefat edit-menu-item-attr-title" name="menu-item-attr-title[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->post_excerpt);
        ?>
" />
					</label>
				</p>
				<p class="field-link-target description">
					<label for="edit-menu-item-target-<?php 
        echo $item_id;
        ?>
">
						<input type="checkbox" id="edit-menu-item-target-<?php 
        echo $item_id;
        ?>
" value="_blank" name="menu-item-target[<?php 
        echo $item_id;
        ?>
]"<?php 
        checked($item->target, '_blank');
        ?>
 />
						<?php 
        _e('Open link in a new window/tab');
        ?>
					</label>
				</p>
				<!-- awesome icon -->
				<p class="description description-thin">
					<label for="edit-menu-item-awesome-<?php 
        echo $item_id;
        ?>
">
						<?php 
        __e('Awesome icon');
        ?>
 <a href="//fortawesome.github.io/Font-Awesome/icons" target="_blank" title="<?php 
        echo ___('Views all icons');
        ?>
">#<?php 
        echo ___('ALL');
        ?>
</a>
						<br />
						<input type="text" id="edit-menu-item-awesome-<?php 
        echo $item_id;
        ?>
" class="widefat edit-menu-item-awesome" name="menu-item-awesome[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo $item->awesome;
        ?>
" list="edit-menu-item-awesome-<?php 
        echo $item_id;
        ?>
-datalist">
						<?php 
        echo icon_option_list('edit-menu-item-awesome-' . $item_id . '-datalist');
        ?>
					</label>
				</p><!-- /awesome icon -->
				
				<p class="field-css-classes description description-thin">
					<label for="edit-menu-item-classes-<?php 
        echo $item_id;
        ?>
">
						<?php 
        _e('CSS Classes (optional)');
        ?>
<br />
						<input type="text" id="edit-menu-item-classes-<?php 
        echo $item_id;
        ?>
" class="widefat code edit-menu-item-classes" name="menu-item-classes[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr(implode(' ', $item->classes));
        ?>
" />
					</label>
				</p>
				<!-- only show icon -->
				<p class="description description-thin field-hide-title">
					<label for="edit-menu-item-hide-title-<?php 
        echo $item_id;
        ?>
">
						<?php 
        echo ___('Toggle navigation label');
        ?>
<br>
						<select id="edit-menu-item-hide-title-<?php 
        echo $item_id;
        ?>
" class="widefat edit-menu-item-hide-title" name="menu-item-hide-title[<?php 
        echo $item_id;
        ?>
]" >
							<option value="-1"><?php 
        echo ___('Show navigation label');
        ?>
</option>
							<option value="1" <?php 
        echo isset($item->hide_title) && $item->hide_title == 1 ? 'select' : null;
        ?>
><?php 
        echo ___('Hide navigation label');
        ?>
</option>
						</select>
					</label>
				</p><!-- /only show icon -->
				
				<p class="field-xfn description description-thin">
					<label for="edit-menu-item-xfn-<?php 
        echo $item_id;
        ?>
">
						<?php 
        _e('Link Relationship (XFN)');
        ?>
<br />
						<input type="text" id="edit-menu-item-xfn-<?php 
        echo $item_id;
        ?>
" class="widefat code edit-menu-item-xfn" name="menu-item-xfn[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->xfn);
        ?>
" />
					</label>
				</p>
				<p class="field-description description description-wide">
					<label for="edit-menu-item-description-<?php 
        echo $item_id;
        ?>
">
						<?php 
        _e('Description');
        ?>
<br />
						<textarea id="edit-menu-item-description-<?php 
        echo $item_id;
        ?>
" class="widefat edit-menu-item-description" rows="3" cols="20" name="menu-item-description[<?php 
        echo $item_id;
        ?>
]"><?php 
        echo esc_html($item->description);
        // textarea_escaped
        ?>
</textarea>
						<span class="description"><?php 
        _e('The description will be displayed in the menu if the current theme supports it.');
        ?>
</span>
					</label>
				</p>

				<p class="field-move hide-if-no-js description description-wide">
					<label>
						<span><?php 
        _e('Move');
        ?>
</span>
						<a href="#" class="menus-move menus-move-up" data-dir="up"><?php 
        _e('Up one');
        ?>
</a>
						<a href="#" class="menus-move menus-move-down" data-dir="down"><?php 
        _e('Down one');
        ?>
</a>
						<a href="#" class="menus-move menus-move-left" data-dir="left"></a>
						<a href="#" class="menus-move menus-move-right" data-dir="right"></a>
						<a href="#" class="menus-move menus-move-top" data-dir="top"><?php 
        _e('To the top');
        ?>
</a>
					</label>
				</p>

				<div class="menu-item-actions description-wide submitbox">
					<?php 
        if ('custom' != $item->type && $original_title !== false) {
            ?>
						<p class="link-to-original">
							<?php 
            printf(__('Original: %s'), '<a href="' . esc_attr($item->url) . '">' . esc_html($original_title) . '</a>');
            ?>
						</p>
					<?php 
        }
        ?>
					<a class="item-delete submitdelete deletion" id="delete-<?php 
        echo $item_id;
        ?>
" href="<?php 
        echo wp_nonce_url(add_query_arg(array('action' => 'delete-menu-item', 'menu-item' => $item_id), admin_url('nav-menus.php')), 'delete-menu_item_' . $item_id);
        ?>
"><?php 
        _e('Remove');
        ?>
</a> <span class="meta-sep hide-if-no-js"> | </span> <a class="item-cancel submitcancel hide-if-no-js" id="cancel-<?php 
        echo $item_id;
        ?>
" href="<?php 
        echo esc_url(add_query_arg(array('edit-menu-item' => $item_id, 'cancel' => time()), admin_url('nav-menus.php')));
        ?>
#menu-item-settings-<?php 
        echo $item_id;
        ?>
"><?php 
        _e('Cancel');
        ?>
</a>
				</div>

				<input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo $item_id;
        ?>
" />
				<input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->object_id);
        ?>
" />
				<input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->object);
        ?>
" />
				<input class="menu-item-data-parent-id" type="hidden" name="menu-item-parent-id[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->menu_item_parent);
        ?>
" />
				<input class="menu-item-data-position" type="hidden" name="menu-item-position[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->menu_order);
        ?>
" />
				<input class="menu-item-data-type" type="hidden" name="menu-item-type[<?php 
        echo $item_id;
        ?>
]" value="<?php 
        echo esc_attr($item->type);
        ?>
" />
			</div><!-- .menu-item-settings-->
			<ul class="menu-item-transport"></ul>
		<?php 
        $output .= ob_get_clean();
    }