Пример #1
0
    /**
     * Outputs the options form on admin
     *
     * @param array $instance The widget options
     */
    public function form($instance)
    {
        $mc_games = new miniclip_games();
        $categories = $mc_games->get_categories();
        if ($categories) {
            $current_category = !empty($instance['category']) ? intval($instance['category']) : 0;
            ?>
<p>
	<label for="<?php 
            echo $this->get_field_name('category');
            ?>
"><?php 
            _e('Game Category:', 'miniclip-games');
            ?>
</label>
	<select id="<?php 
            echo $this->get_field_id('category');
            ?>
" name="<?php 
            echo $this->get_field_name('category');
            ?>
" >';
<?php 
            foreach ($categories as $cat) {
                echo '<option value="' . intval($cat['category_id']) . '" ' . selected(intval($cat['category_id']), $current_category) . ' >' . esc_html($cat['name']) . '</option>';
            }
            ?>
	</select>
</p>
<?php 
        }
    }
Пример #2
0
/**
 * Game Category
 *
 * @param type $atts
 * @return type
 */
function mc_shortcode_category($atts)
{
    $atts = shortcode_atts(array('id' => 0), $atts);
    extract($atts);
    // nothing to do so lets go
    if (empty($id)) {
        return;
    }
    $mc_games = new miniclip_games();
    return $mc_games->embed_category($id);
}
 /**
  * Outputs the options form on admin
  *
  * @param array $instance The widget options
  */
 public function form($instance)
 {
     $mc_games = new miniclip_games();
     $categories = $mc_games->get_categories();
     if ($categories) {
         $current_category = !empty($instance['category']) ? intval($instance['category']) : 0;
         echo '<select id="' . $this->get_field_id('category') . '" name="' . $this->get_field_name('category') . '" >';
         foreach ($categories as $cat) {
             echo '<option value="' . intval($cat['category_id']) . '" ' . selected() . ' >' . esc_html($cat['name']) . '</option>';
         }
         echo '</select>';
     }
 }