/**
  * Constructor
  */
 public function __construct()
 {
     add_action('add_meta_boxes', array($this, 'remove_meta_boxes'), 10);
     add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 20);
     add_action('save_post', array($this, 'save_meta_boxes'), 1, 2);
     // clear category transients
     add_action('documentate_process_documentate_meta', array(Docu()->admin, 'clear_transients'));
 }
 /**
  * Enqueue admin scripts
  *
  * @param	str $hook
  * @return	array
  */
 public function enqueue_scripts($hook)
 {
     $screen = get_current_screen();
     $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
     // Edit document category pages
     if ('edit-tags.php' == $hook && in_array($screen->id, array('edit-docu_cat'))) {
         wp_enqueue_media();
         $docu_media_params = array('title' => __("Choose an image", "documentate"), 'button' => __("Use image", "documentate"), 'placeholder' => documentate_placeholder_img_src());
         wp_enqueue_script('documentate_term_thunbnails', Docu()->plugin_url() . '/assets/js/admin/term-thumbnails' . $suffix . '.js', array('jquery', 'media-editor'), Docu()->version, true);
         wp_localize_script('documentate_term_thunbnails', 'DOCUMENTATE_MEDIA_PARAMS', $docu_media_params);
     }
     // Term ordering - only when sorting by term_order
     if (!empty($_GET['taxonomy']) && in_array($_GET['taxonomy'], apply_filters('documentate_sortable_taxonomies', array('docu_cat'))) && !isset($_GET['orderby'])) {
         wp_enqueue_script('documentate_term_ordering', Docu()->plugin_url() . '/assets/js/admin/term-ordering' . $suffix . '.js', array('jquery-ui-sortable'), Docu()->version, true);
         $taxonomy = isset($_GET['taxonomy']) ? sanitize_text_field($_GET['taxonomy']) : '';
         $docu_term_order_params = array('taxonomy' => $taxonomy);
         wp_localize_script('documentate_term_ordering', 'DOCUMENTATE_TERM_ORDER_PARAMS', $docu_term_order_params);
     }
 }
 /**
  * Sanitize and validate plugin settings
  * @param  array $input
  * @return array
  * @since  1.0.0
  */
 public function validate_settings($input)
 {
     $clean = array();
     $clean['archive_page_id'] = isset($input['archive_page_id']) && !is_wp_error(get_post(intval($input['archive_page_id']))) ? intval($input['archive_page_id']) : 0;
     $clean['archive_display'] = isset($input['archive_display']) && in_array($input['archive_display'], array('documents', 'subcategories', 'both')) ? $input['archive_display'] : 'subcategories';
     $clean['docu_qty'] = isset($input['archive_display']) ? intval($input['docu_qty']) : 0;
     $clean['category_display'] = isset($input['category_display']) && in_array($input['category_display'], array('documents', 'subcategories', 'both')) ? $input['category_display'] : 'subcategories';
     $clean['search_setting'] = isset($input['search_setting']) && $input['search_setting'] == 'show' ? 'show' : 'hide';
     $clean['breadcrumbs_setting'] = isset($input['breadcrumbs_setting']) && $input['breadcrumbs_setting'] == 'show' ? 'show' : 'hide';
     $radio = array('left', 'right', 'hide');
     $clean['sidebar'] = isset($input['sidebar']) && $input['sidebar'] == 'show' ? 'show' : 'hide';
     $clean['comments_setting'] = isset($input['comments_setting']) && $input['comments_setting'] == 'show' ? 'show' : 'hide';
     $clean['uninstall_mode'] = isset($input['uninstall_mode']) && in_array($input['uninstall_mode'], array('nuclear', 'settings', 'none')) ? $input['uninstall_mode'] : 'hide';
     // maybe clear category transients
     $docu_qty = max(array(documentate_get_option('docu_qty'), documentate_get_option('cat_docu_qty')));
     if (isset($clean['docu_qty']) && $clean['docu_qty'] > $docu_qty || isset($clean['cat_docu_qty']) && $clean['cat_docu_qty'] > $docu_qty) {
         Docu()->admin->clear_transients();
     }
     return $clean;
 }
/**
 * Get template part (for templates like the shop-loop).
 *
 * @access public
 * @param mixed $slug
 * @param string $name (default: '')
 * @since   1.0.0
 */
function documentate_get_template_part($slug, $name = '')
{
    $template_path = documentate_get_template_path();
    $template = '';
    // Look in yourtheme/slug-name.php and yourtheme/documentate/slug-name.php
    if ($name && !DOCUMENTATE_TEMPLATE_DEBUG_MODE) {
        $template = locate_template(array("{$slug}-{$name}.php", $template_path . "{$slug}-{$name}.php"));
    }
    // Get default slug-name.php
    if (!$template && $name && file_exists(Docu()->plugin_path() . "/templates/{$slug}-{$name}.php")) {
        $template = Docu()->plugin_path() . "/templates/{$slug}-{$name}.php";
    }
    // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/documentate/slug.php
    if (!$template && !DOCUMENTATE_TEMPLATE_DEBUG_MODE) {
        $template = locate_template(array("{$slug}.php", $template_path . "{$slug}.php"));
    }
    // Allow 3rd party plugin filter template file from their plugin
    if (!$template && DOCUMENTATE_TEMPLATE_DEBUG_MODE || $template) {
        $template = apply_filters('documentate_get_template_part', $template, $slug, $name);
    }
    if ($template) {
        load_template($template, false);
    }
}
 /**
  * Update version to current
  */
 private static function update_version()
 {
     delete_option('documentate_version');
     add_option('documentate_version', Docu()->version);
 }
Esempio n. 6
0
                define('DOCU_PLUGIN_FILE', __FILE__);
            }
        }
        private function includes()
        {
            require_once DOCU_PLUGIN_DIR . 'includes/post-types.php';
            require_once DOCU_PLUGIN_DIR . 'includes/load-js-css.php';
            require_once DOCU_PLUGIN_DIR . 'includes/docu-functions.php';
            //require_once DOCU_PLUGIN_DIR . 'includes/class-gamajo-template-loader.php';
            require_once DOCU_PLUGIN_DIR . 'includes/class-docu-template-loader.php';
            require_once DOCU_PLUGIN_DIR . 'includes/shortcodes.php';
            require_once DOCU_PLUGIN_DIR . 'includes/sortable/sortable.php';
            require_once DOCU_PLUGIN_DIR . 'includes/widgets.php';
            require_once DOCU_PLUGIN_DIR . 'includes/install.php';
        }
        public function __clone()
        {
            _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'docu'), DOCU_VERSION);
        }
        public function __wakeup()
        {
            _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'docu'), DOCU_VERSION);
        }
    }
}
function Docu()
{
    return Docu::instance();
}
Docu();
/**
 * Get the placeholder image URL for documents etc
 *
 * @access public
 * @return string
 */
function documentate_placeholder_img_src()
{
    return apply_filters('documentate_placeholder_img_src', Docu()->plugin_url() . '/assets/images/placeholder.png');
}
 /**
  * Documentate Enqueue Documentate frontend scripts/styles
  * @since  1.0.0
  */
 public function frontend_scripts()
 {
     wp_enqueue_style('documentate-frontend', Docu()->plugin_url() . '/assets/css/documentate-frontend-style.css', array('dashicons'), Docu()->version);
     wp_register_script('live-search', Docu()->plugin_url() . '/assets/js/jquery.livesearch.js', array('jquery'), '2.0', true);
     wp_register_script('documentate', Docu()->plugin_url() . '/assets/js/documentate.js', array('jquery', 'live-search'), Docu()->version, true);
 }