Beispiel #1
0
    public function widget($args, $instance)
    {
        echo $args['before_widget'];
        if (!empty($instance['title'])) {
            echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title'];
        }
        $instance = wp_parse_args((array) $instance, $this->defaults);
        // main widget container
        echo '<div id="my-' . $this->id . '">';
        // updated container
        echo '<div class="pwppr-posts-container">';
        echo get_pwppr_posts($instance);
        echo '</div>';
        ?>

            <?php 
        // variables for js
        wp_localize_script('pwppr-scripts', 'pwppr_' . $this->number, array('id' => $this->id, 'maxitems' => $this->maxitems, 'items2show' => $instance['items2show']));
        ?>

            <?php 
        // operation container
        echo '<div class="pwpprRefreshCont" style="background-image:url(' . PWPPR_HOME_URL . 'images/spin-' . $instance['colorScheme'] . '.gif);">
                      <div class="userInputCont" style="border: 2px solid ' . $this->colorSchemes[$instance['colorScheme']] . '">
                      <input name="userNumPosts" class="userNumPosts" type="text"  
                             data-idnumber="' . $this->number . '"
                             title="' . __('Enter posts count', 'pwppr') . '"
                             value="' . $instance['items2show'] . '" />
                             </div>
                      <div class="ajaxSpinBtn" 
                             data-idnumber="' . $this->number . '"
                             ></div>
                      <div class="ajaxSquareBtn"
                             data-idnumber="' . $this->number . '"
                             ><span>' . $instance['buttonText'] . '</span></div>
                  </div>';
        echo '</div>';
        //my-pwppr-xx
        echo $args['after_widget'];
    }
Beispiel #2
0
 public function ajax_actions()
 {
     check_ajax_referer('pwppr_nonce', 'nonce');
     if (!isset($_POST['flag'])) {
         wp_send_json_error(__('error: Empty ajax flag', 'pwpcs'));
     }
     if ($_POST['flag'] == "pwpprPostRefreshFlag") {
         $wdgt_num = $_POST['number'];
         $pwppr_ajax = new PWP_Photoroulette_Widget();
         $options = get_option($pwppr_ajax->option_name);
         $options = $options[$wdgt_num];
         if (!empty($_POST['numPosts'])) {
             $options['items2show'] = $_POST['numPosts'];
         }
         $posts = get_pwppr_posts($options);
         if (!empty($posts)) {
             wp_send_json_success($posts);
         } else {
             wp_send_json_error(__('error: No posts found', 'pwpcs'));
         }
     }
 }