Ejemplo n.º 1
0
 public function __construct()
 {
     $this->post_type_repo = new PostTypeRepository();
     $this->setPluginVersion();
     add_action('admin_enqueue_scripts', array($this, 'styles'));
     add_action('admin_enqueue_scripts', array($this, 'scripts'));
     $this->plugin_dir = Helpers::plugin_url();
 }
Ejemplo n.º 2
0
 /**
  * Loop through all the pages and create the nested / sortable list
  * Recursive Method, called in page.php view
  */
 private function loopPosts($parent_id = 0, $count = 0)
 {
     $this->setTaxonomies();
     if ($this->post_type->name == 'page') {
         $post_type = array('page');
         if (!$this->settings->menusDisabled()) {
             $post_type[] = 'np-redirect';
         }
     } else {
         $post_type = array($this->post_type->name);
         $post_type[] = 'np-redirect';
     }
     $query_args = array('post_type' => $post_type, 'posts_per_page' => -1, 'author' => $this->sort_options->author, 'orderby' => $this->sort_options->orderby, 'post_status' => array('publish', 'pending', 'draft', 'private', 'future', 'trash'), 'post_parent' => $parent_id, 'order' => $this->sort_options->order);
     if ($this->isSearch()) {
         $query_args = $this->searchParams($query_args);
     }
     if ($this->isFiltered()) {
         $query_args = $this->filterParams($query_args);
     }
     $pages = new \WP_Query(apply_filters('nestedpages_page_listing', $query_args));
     if ($pages->have_posts()) {
         $count++;
         if ($this->publishCount($pages) > 1) {
             $this->listOpening($pages, $count);
         }
         while ($pages->have_posts()) {
             $pages->the_post();
             global $post;
             $this->setPost($post);
             if ($this->post->status !== 'trash') {
                 echo '<li id="menuItem_' . $this->post->id . '" class="page-row';
                 // Published?
                 if ($this->post->status == 'publish') {
                     echo ' published';
                 }
                 if ($this->post->status == 'draft') {
                     echo ' draft';
                 }
                 // Hidden in Nested Pages?
                 if ($this->post->np_status == 'hide') {
                     echo ' np-hide';
                 }
                 // Taxonomies
                 echo ' ' . $this->post_repo->getTaxonomyCSS($this->post->id, $this->h_taxonomies);
                 echo ' ' . $this->post_repo->getTaxonomyCSS($this->post->id, $this->f_taxonomies, false);
                 echo '">';
                 $count++;
                 $row_view = $this->post->type !== 'np-redirect' ? 'partials/row' : 'partials/row-link';
                 include Helpers::view($row_view);
             }
             // trash status
             if (!$this->isSearch()) {
                 $this->loopPosts($this->post->id, $count);
             }
             if ($this->post->status !== 'trash') {
                 echo '</li>';
             }
         }
         // Loop
         if ($this->publishCount($pages) > 1) {
             echo '</ol>';
         }
     }
     wp_reset_postdata();
 }
 /**
  * Save a new Redirect
  * @since 1.1
  * @param array data
  */
 public function saveRedirect($data)
 {
     $this->validation->validateRedirect($data);
     $new_link = array('post_title' => sanitize_text_field($data['np_link_title']), 'post_status' => sanitize_text_field($data['_status']), 'post_content' => Helpers::check_url($data['np_link_content']), 'post_parent' => sanitize_text_field($data['parent_id']), 'post_type' => 'np-redirect', 'post_excerpt' => '');
     $this->new_id = wp_insert_post($new_link);
     $this->updateNavStatus($data);
     $this->updateNestedPagesStatus($data);
     $this->updateLinkTarget($data);
     return $this->new_id;
 }
Ejemplo n.º 4
0
 /**
  * Display the Settings Page
  * Callback for registerSettingsPage method
  */
 public function settingsPage()
 {
     $this->setMenu();
     $tab = isset($_GET['tab']) ? $_GET['tab'] : 'general';
     include Helpers::view('settings/settings');
 }
Ejemplo n.º 5
0
 /**
  * Format the new link for AJAX response
  */
 private function formatLink()
 {
     $this->data['np_link_content'] = Helpers::check_url($this->data['np_link_content']);
 }
 /**
  * Sync Link Menu Item
  * @since 1.1.4
  */
 private function syncLinkItem($menu_parent, $menu_item_id)
 {
     $menu = wp_update_nav_menu_item($this->id, $menu_item_id, array('menu-item-title' => $this->post->title, 'menu-item-position' => $this->count, 'menu-item-url' => Helpers::check_url(get_the_content($this->post->id)), 'menu-item-attr-title' => $this->post->nav_title_attr, 'menu-item-status' => 'publish', 'menu-item-classes' => $this->post->nav_css, 'menu-item-type' => 'custom', 'menu-item-object' => 'np-redirect', 'menu-item-object-id' => $this->post->id, 'menu-item-parent-id' => $menu_parent, 'menu-item-xfn' => $this->post->id, 'menu-item-target' => $this->post->link_target));
     return $menu;
 }