/** * Enqueues CSS, JavaScript, etc * * @mvc Controller */ public static function load_resources() { wp_register_style(self::PREFIX . 'wpctc', plugins_url('css/wpctc.min.css', dirname(__FILE__)), array(), self::VERSION, 'all'); wp_register_script(self::PREFIX . 'jquery-tagcanvas', plugins_url('javascript/jquery.tagcanvas.min.js', dirname(__FILE__)), array('jquery'), self::VERSION, true); wp_register_script(self::PREFIX . 'wpctc-tagcanvas', plugins_url('javascript/wpctc.tagcanvas.min.js', dirname(__FILE__)), array('jquery', self::PREFIX . 'jquery-tagcanvas'), self::VERSION, true); wp_register_script(self::PREFIX . 'wp-category-tag-cloud-admin', plugins_url('javascript/wp-category-tag-cloud-admin.min.js', dirname(__FILE__)), array('jquery'), self::VERSION, true); wp_register_script(self::PREFIX . 'wp-category-tag-cloud', plugins_url('javascript/wp-category-tag-cloud.min.js', dirname(__FILE__)), array('jquery'), self::VERSION, true); wp_register_script(self::PREFIX . 'jquery-style', plugins_url('javascript/jquery.style.min.js', dirname(__FILE__)), array('jquery'), self::VERSION, true); error_log("bla=" . print_r(WPCTC_Settings::get_instance()->settings['general']['do-not-load-scripts'], true)); error_log("bla=" . (!isset(WPCTC_Settings::get_instance()->settings['general']) ? "true" : "false")); error_log("bla=" . (!isset(WPCTC_Settings::get_instance()->settings['general']['do-not-load-scripts']) ? "true" : "false")); error_log("bla=" . (WPCTC_Settings::get_instance()->settings['general']['do-not-load-scripts'] != 1 ? "true" : "false")); if (is_admin()) { wp_enqueue_style('farbtastic'); wp_enqueue_script('farbtastic'); wp_enqueue_script(self::PREFIX . 'wp-category-tag-cloud-admin'); } elseif (!isset(WPCTC_Settings::get_instance()->settings['general']) || !isset(WPCTC_Settings::get_instance()->settings['general']['do-not-load-scripts']) || WPCTC_Settings::get_instance()->settings['general']['do-not-load-scripts'] != 1) { wp_enqueue_style(self::PREFIX . 'wpctc'); wp_enqueue_script(self::PREFIX . 'jquery-tagcanvas'); wp_enqueue_script(self::PREFIX . 'wpctc-tagcanvas'); wp_enqueue_script(self::PREFIX . 'jquery-style'); wp_enqueue_script(self::PREFIX . 'wp-category-tag-cloud'); } }
/** * @param array $new_instance * @param array $old_instance * * @return array */ function update($new_instance, $old_instance) { $instance = array(); $instance['title'] = !empty($new_instance['title']) ? strip_tags($new_instance['title']) : __('New title', 'wpctc_widget_domain'); $instance['exclude'] = !empty($new_instance['exclude']) ? strip_tags($new_instance['exclude']) : ''; $instance['font'] = !empty($new_instance['font']) ? strip_tags($new_instance['font']) : ''; $custom_taxonomies = get_taxonomies(array('public' => true, '_builtin' => false), 'objects', 'and'); if ($custom_taxonomies) { foreach ($custom_taxonomies as $custom_taxonomy) { $instance[$custom_taxonomy->name . '_id'] = isset($new_instance[$custom_taxonomy->name . '_id']) ? $new_instance[$custom_taxonomy->name . '_id'] : array(); } } $instance['post_type'] = isset($new_instance['post_type']) ? $new_instance['post_type'] : array(); $instance['author'] = isset($new_instance['author']) ? $new_instance['author'] : array(); $instance['category_id'] = isset($new_instance['category_id']) ? $new_instance['category_id'] : array(); $instance['child_categories'] = isset($new_instance['child_categories']) ? $new_instance['child_categories'] : "0"; $instance['opacity'] = isset($new_instance['opacity']) ? $new_instance['opacity'] : "0"; $instance['tilt'] = isset($new_instance['tilt']) ? $new_instance['tilt'] : "0"; $instance['colorize'] = isset($new_instance['colorize']) ? $new_instance['colorize'] : "0"; $instance['nofollow'] = isset($new_instance['nofollow']) ? $new_instance['nofollow'] : "0"; $instance['cache'] = isset($new_instance['cache']) ? $new_instance['cache'] : "0"; $instance['tag_id'] = isset($new_instance['tag_id']) ? $new_instance['tag_id'] : array(); $instance['order_by'] = isset($new_instance['order_by']) && strlen($new_instance['order_by']) > 0 ? $new_instance['order_by'] : 'name'; $instance['order'] = isset($new_instance['order']) && strlen($new_instance['order']) > 0 ? $new_instance['order'] : 'ASC'; $instance['format'] = isset($new_instance['format']) && strlen($new_instance['format']) > 0 ? $new_instance['format'] : 'flat'; $instance['number'] = isset($new_instance['number']) && (is_int($new_instance['number']) || ctype_digit($new_instance['number'])) ? $new_instance['number'] : 0; $instance['post_age'] = isset($new_instance['post_age']) && (is_int($new_instance['post_age']) || ctype_digit($new_instance['post_age'])) ? $new_instance['post_age'] : 0; $instance['post_count'] = isset($new_instance['post_count']) && (is_int($new_instance['post_count']) || ctype_digit($new_instance['post_count'])) ? $new_instance['post_count'] : 0; $instance['taxonomy'] = isset($new_instance['taxonomy']) && strlen($new_instance['taxonomy']) > 0 ? $new_instance['taxonomy'] : 'post_tag'; $instance['width'] = isset($new_instance['width']) && is_numeric($new_instance['width']) ? $new_instance['width'] : 0; $instance['height'] = isset($new_instance['height']) && is_numeric($new_instance['height']) ? $new_instance['height'] : 0; $instance['radiusx'] = isset($new_instance['radiusx']) ? $new_instance['radiusx'] : '1'; $instance['radiusy'] = isset($new_instance['radiusy']) ? $new_instance['radiusy'] : '1'; $instance['radiusz'] = isset($new_instance['radiusz']) ? $new_instance['radiusz'] : '1'; $instance['zoom'] = isset($new_instance['zoom']) && is_numeric($new_instance['zoom']) ? $new_instance['zoom'] : 1; $instance['timeout'] = isset($new_instance['timeout']) && is_numeric($new_instance['timeout']) ? $new_instance['timeout'] : 60; $instance['smallest'] = isset($new_instance['smallest']) && (is_int($new_instance['smallest']) || ctype_digit($new_instance['smallest'])) ? $new_instance['smallest'] : 75; $instance['largest'] = isset($new_instance['largest']) && (is_int($new_instance['largest']) || ctype_digit($new_instance['largest'])) ? $new_instance['largest'] : 200; $color = !empty($new_instance['color']) ? strip_tags($new_instance['color']) : ''; if (!preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', $color)) { $color = ''; } $instance['color'] = $color; $background = !empty($new_instance['background']) ? strip_tags($new_instance['background']) : ''; if (!preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', $background)) { $background = ''; } $instance['background'] = $background; $border = !empty($new_instance['border']) ? strip_tags($new_instance['border']) : ''; if (!preg_match('/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', $border)) { $border = ''; } $instance['border'] = $border; if (isset(WPCTC_Settings::get_instance()->settings) && isset(WPCTC_Settings::get_instance()->settings['general']) && isset(WPCTC_Settings::get_instance()->settings['general']['clear-cache-on-save']) && WPCTC_Settings::get_instance()->settings['general']['clear-cache-on-save'] == 1) { WordPress_Category_Tag_Cloud::clear_caching_plugins(); } return $instance; }
/** * Initializes variables * * @mvc Controller */ public function init() { self::$default_settings = self::get_default_settings(); $this->settings = self::get_settings(); }