예제 #1
0
 function popup_autopost($data = array())
 {
     echo $this->messages(true);
     $output = '';
     // container
     $output .= '<div class="popup_content inline_form autopost">';
     // form
     $output .= '<form enctype="multipart/form-data" method="post" action="" class="" id="autopost-form">';
     // basic options
     $output .= '<div id="basic">';
     $helper_articles = WYSIJA::get('articles', 'helper');
     $output .= '<div class="block clearfix">';
     $output .= '    <label>' . __('Post type', WYSIJA) . '</label>';
     $output .= $helper_articles->field_select_post_type(array('value' => $data['params']['post_type']));
     $output .= '</div>';
     // post limit
     if ($data['autopost_type'] === 'single') {
         $output .= '<input type="hidden" name="post_limit" value="1" />';
     } else {
         $output .= '<div class="block clearfix">';
         $output .= '    <label>' . __('Maximum of posts to show', WYSIJA) . '</label>';
         $output .= '    <select name="post_limit" id="post_limit">';
         foreach ($data['post_limits'] as $limit) {
             $output .= '    <option value="' . $limit . '" ' . ($limit === (int) $data['params']['post_limit'] ? 'selected="selected"' : '') . ' >' . $limit . '</option>';
         }
         $output .= '    </select>';
         $output .= '</div>';
     }
     // Get selected terms IDs
     $terms_selected = array_filter(isset($data['params']['category_ids']) ? explode(',', trim($data['params']['category_ids'])) : array());
     // Create the init selection in to be in the Select2 format of results
     $_attr_init_selection = array();
     // Only build if there are any selected terms
     if (!empty($terms_selected)) {
         $taxonomies = get_taxonomies(array(), 'objects');
         $terms = get_terms(array_keys($taxonomies), array('include' => $terms_selected, 'hide_empty' => false));
         foreach ($terms as $term) {
             $_attr_init_selection[] = array('id' => $term->term_id, 'text' => wp_kses($taxonomies[$term->taxonomy]->labels->singular_name . ': ' . $term->name, array()));
         }
     }
     // categories
     $output .= '<div class="block clearfix" id="categories_filters">' . '<label title="' . esc_attr__('And taxonomies as well...', WYSIJA) . '">' . __('Categories and tags', WYSIJA) . '</label>' . '<div class="group">' . '<p class="category_select clearfix">' . '<input data-placeholder="' . __('Select...', WYSIJA) . '" name="category_ids" style="width: 300px" class="category_ids mailpoet-field-select2-terms" data-multiple="true" data-value=\'' . WJ_Utils::esc_json_attr($_attr_init_selection) . '\' value="' . esc_attr(implode(',', $terms_selected)) . '" type="hidden">' . '</p>' . '</div>' . '</div>';
     // end - basic options
     $output .= '</div>';
     // display options
     $output .= '<p><a id="toggle-advanced" href="javascript:;">' . __('Show display options', WYSIJA) . '</a></p>';
     $output .= '<div id="advanced">';
     $output .= $this->_post_display_options($data);
     $output .= '</div>';
     $output .= '    <p class="submit_button"><input type="submit" id="autopost-submit" class="button-primary" name="submit" value="' . __('Done', WYSIJA) . '" /></p>';
     $output .= '</form>';
     $output .= '</div>';
     echo $output;
 }