function simple_links_load() { Simple_Links_Categories::get_instance(); Simple_Links_WP_Links::init(); add_action('init', array('Simple_Link', 'register_sl_post_type')); if (is_admin()) { Simple_Links_Settings::init(); Simple_Links_Sort::init(); Simple_Links_Visual_Shortcodes::init(); } }
/** * Form * * Outputs the Widget form on the /wp-admin/widgets.php Page * * @see WP_Widget::form() * */ function form($instance) { global $simple_links; $instance = $this->migrateOldData($instance); $instance = wp_parse_args($instance, $this->defaults); ?> <input type="hidden" name="<?php echo $this->get_field_name('simple_links_version'); ?> " value="<?php echo SIMPLE_LINKS_VERSION; ?> "/> <em><?php _e('Be sure the see the Help section in the top right corner of the screen for questions!', 'simple-links'); ?> </em> <p> <strong><?php _e('Links Title', 'simple-links'); ?> :</strong> <input class="simple-links-title widefat" type="text" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo esc_attr($instance['title']); ?> " /> </p> <strong><?php _e('Order Links By', 'simple-links'); ?> </strong> <select id="<?php echo $this->get_field_id('orderby'); ?> " name="<?php echo $this->get_field_name('orderby'); ?> "> <?php simple_links::orderby_options($instance['orderby']); ?> </select> <p> <strong> <?php _e('Order', 'simple-links'); ?> : </strong> <select id="<?php echo $this->get_field_id('order'); ?> " name="<?php echo $this->get_field_name('order'); ?> "> <option value="ASC" <?php selected($instance['order'], 'ASC'); ?> > <?php _e('Ascending', 'simple-links'); ?> </option> <option value="DESC" <?php selected($instance['order'], 'DESC'); ?> > <?php _e('Descending', 'simple-links'); ?> </option> </select> </p> <p> <strong> <?php _e('Categories (optional)', 'simple-links'); ?> : </strong> <?php $cats = Simple_Links_Categories::get_category_names(); if (!empty($cats)) { $term_args = array('walker' => new Simple_Links_Category_Checklist($this->get_field_name('category'), $instance['category']), 'taxonomy' => Simple_Links_Categories::TAXONOMY, 'checked_ontop' => false); ?> <ul class="sl-categories"> <?php wp_terms_checklist(0, $term_args); ?> </ul> <?php } else { _e('No link categories have been created yet.', 'simple-links'); } ?> </p> <p> <strong><?php _e('Include Child Categories Of Selected Categories', 'simple-links'); ?> </strong> <input type="checkbox" id="<?php echo $this->get_field_id('include_child_categories'); ?> " name="<?php echo $this->get_field_name('include_child_categories'); ?> " <?php checked($instance['include_child_categories']); ?> value="1"/> </p> <hr> <p> <strong><?php _e('Number Of Links', 'simple-links'); ?> :</strong> <select id="<?php echo $this->get_field_id('numberposts'); ?> " name="<?php echo $this->get_field_name('numberposts'); ?> "> <option value="-1">All</option> <?php for ($i = 1; $i < 50; $i++) { printf('<option value="%s" %s>%s</option>', $i, selected($instance['numberposts'], $i), $i); } ?> </select> </p> <strong><?php _e('Show Description', 'simple-links'); ?> </strong> <input type="checkbox" id="<?php echo $this->get_field_id('description'); ?> " name="<?php echo $this->get_field_name('description'); ?> " <?php checked($instance['description']); ?> value="1"/> <br> <p> <strong><?php _e('Include Description Paragraph Format', 'simple-links'); ?> </strong> <input type="checkbox" id="<?php echo $this->get_field_id('show_description_formatting'); ?> " name="<?php echo $this->get_field_name('show_description_formatting'); ?> " <?php checked($instance['show_description_formatting']); ?> value="1"/> </p> <hr> <p> <strong><?php _e('Show Image', 'simple-links'); ?> </strong> <input type="checkbox" id="<?php echo $this->get_field_id('show_image'); ?> " name="<?php echo $this->get_field_name('show_image'); ?> " <?php checked($instance['show_image']); ?> value="1"/> </p> <p> <strong><?php _e('Remove Line Break Between Image and Link', 'simple-links'); ?> </strong> <input type="checkbox" id="<?php echo $this->get_field_id('remove_line_break'); ?> " name="<?php echo $this->get_field_name('remove_line_break'); ?> " <?php checked($instance['remove_line_break']); ?> value="1"/> </p> <strong><?php _e('Display Image Without Title', 'simple-links'); ?> </strong> <input type="checkbox" id="<?php echo $this->get_field_id('show_image_only'); ?> " name="<?php echo $this->get_field_name('show_image_only'); ?> " <?php checked($instance['show_image_only']); ?> value="1"/> <br> <p> <strong><?php _e('Image Size', 'simple-links'); ?> :</strong> <select id="<?php echo $this->get_field_id('image_size'); ?> " name="<?php echo $this->get_field_name('image_size'); ?> "> <?php foreach ($simple_links->image_sizes() as $size) { printf('<option value="%s" %s>%s</option>', $size, selected($instance['image_size'], $size), $size); } ?> </select> </p> <hr> <br> <strong> <?php _e('Display Additional Fields', 'simple-links'); ?> : </strong> <br> <?php $fields = $simple_links->getAdditionalFields(); if (empty($fields)) { echo '<em>' . __('There have been no additional fields added.', 'simple-links') . '</em>'; } else { foreach ($fields as $field) { if (!isset($instance['fields'][$field])) { $instance['fields'][$field] = 0; } printf(' <input type="checkbox" style="margin: 3px 0" value="%s" name="%s[%s]" %s/> %s <br>', $field, $this->get_field_name('fields'), $field, checked($instance['fields'][$field], $field, false), $field); } } ?> <p> <strong><?php _e('Field Separator', 'simple-links'); ?> :</strong> <br> <em><?php _e('HTML is allowed', 'simple-links'); ?> : - e.g. '<br>'</em> <br> <input type="text" id="<?php echo $this->get_field_id('separator'); ?> " name="<?php echo $this->get_field_name('separator'); ?> " value="<?php echo esc_attr($instance['separator']); ?> " class="widefat"/> </p> <?php do_action('simple_links_widget_form', $instance, $this); }
_e('Title <small>(optional)</small>', 'simple-links'); ?> : <br/> <input type="text" id="title" size="50"/> </label> <fieldset> <legend><?php _e('Categories <small>(optional)</small>', 'simple-links'); ?> </legend> <ul class="sl-categories"> <?php $cats = Simple_Links_Categories::get_category_names(); if (!empty($cats)) { $term_args = array('walker' => new Simple_Links_Category_Checklist(), 'taxonomy' => Simple_Links_Categories::TAXONOMY, 'checked_ontop' => false); wp_terms_checklist(0, $term_args); } else { _e('No link categories have been created yet.', 'simple-links'); } ?> </ul> </fieldset> <p> <label><?php _e('Include Child Categories Of Selected Categories', 'simple-links'); ?>
/** * Retrieve the proper links based on argument set earlier * * @return obj * * @since 1.7.14 */ protected function getLinks() { $this->query_args['post_type'] = Simple_Link::POST_TYPE; $this->query_args['posts_per_page'] = $this->query_args['numberposts']; $this->query_args['posts_per_archive_page'] = $this->query_args['numberposts']; // If we are retrieving a single category and ordering by menu order // we need to use our special retrieval method to maintain order by that category if ($this->query_args['orderby'] == 'menu_order' && !empty($this->query_args['tax_query'][0]['terms']) && count($this->query_args['tax_query'][0]['terms']) == 1) { $links = Simple_Links_Categories::get_instance()->get_links_by_category($this->query_args['tax_query'][0]['terms'][0], $this->query_args['numberposts'], $this->args['include_child_categories']); } else { $links = get_posts($this->query_args); } $links = apply_filters('simple_links_object', $links, $this->args, $this); //backwards compatible $links = apply_filters('simple_links_' . $this->args['type'] . '_links_object', $links, $this->args); $links = apply_filters('simple_links_' . $this->args['type'] . '_links_object_' . $this->args['id'], $links, $this->args); return $this->links = $links; }
/** * Get Links By Category * * Called via ajax to replenish the links ordering list when a category is selected. * We do it honor a 200 links limit per category as well. * * @return void */ public function ajax_get_links_by_category() { $links = Simple_Links_Categories::get_instance()->get_links_by_category($_POST['category_id']); require SIMPLE_LINKS_DIR . 'admin-views/draggable-links.php'; die; }
/** * @deprecated use Simple_Links_Categories::get_category_names() * * @todo find all uses of this and convert to new object * */ function get_categories() { return Simple_Links_Categories::get_category_names(); }
/** * Get (and instantiate, if necessary) the instance of the class * * @static * @return $this */ public static function get_instance() { if (!is_a(self::$instance, __CLASS__)) { self::$instance = new self(); } return self::$instance; }