/** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Load the base class object. $this->base = Soliloquy::get_instance(); // Export a slider. $this->export_slider(); }
/** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Load the base class object. $this->base = Soliloquy::get_instance(); // Add custom settings submenu. add_action('admin_menu', array($this, 'admin_menu')); // Add callbacks for settings tabs. add_action('soliloquy_tab_settings_general', array($this, 'settings_general_tab')); add_action('soliloquy_tab_settings_addons', array($this, 'settings_addons_tab')); // Add the settings menu item to the Plugins table. add_filter('plugin_action_links_' . plugin_basename(plugin_dir_path(dirname(dirname(__FILE__))) . 'soliloquy.php'), array($this, 'settings_link')); // Check if the soliloquy-publishing-default option is set. If not, default it to active $publishing_default = get_option('soliloquy-publishing-default'); if (!$publishing_default) { update_option('soliloquy-publishing-default', 'active'); } // Possibly add a callback for upgrading. $upgrade_lite = get_option('soliloquy_upgrade'); if ($upgrade_lite) { return; } $v1_license = get_option('soliloquy_license_key'); if (!$v1_license) { return; } add_action('soliloquy_tab_settings_upgrade', array($this, 'settings_upgrade_tab')); }
/** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Load the base class object. $this->base = Soliloquy::get_instance(); // Add a custom media button to the editor. add_filter('media_buttons_context', array($this, 'media_button')); }
/** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Load the base class object. $this->base = Soliloquy::get_instance(); // Import a slider. $this->import_slider(); // Add any notices generated by the import script. add_action('admin_notices', array($this, 'notices')); }
/** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Load the base class object. $this->base = Soliloquy::get_instance(); // Build the labels for the post type. $labels = apply_filters('soliloquy_post_type_labels', array('name' => __('Soliloquy Sliders', 'soliloquy'), 'singular_name' => __('Soliloquy', 'soliloquy'), 'add_new' => __('Add New', 'soliloquy'), 'add_new_item' => __('Add New Soliloquy Slider', 'soliloquy'), 'edit_item' => __('Edit Soliloquy Slider', 'soliloquy'), 'new_item' => __('New Soliloquy Slider', 'soliloquy'), 'view_item' => __('View Soliloquy Slider', 'soliloquy'), 'search_items' => __('Search Soliloquy Sliders', 'soliloquy'), 'not_found' => __('No Soliloquy sliders found.', 'soliloquy'), 'not_found_in_trash' => __('No Soliloquy sliders found in trash.', 'soliloquy'), 'parent_item_colon' => '', 'menu_name' => __('Soliloquy', 'soliloquy'))); // Build out the post type arguments. $args = apply_filters('soliloquy_post_type_args', array('labels' => $labels, 'public' => false, 'exclude_from_search' => false, 'show_ui' => true, 'show_in_admin_bar' => false, 'rewrite' => false, 'query_var' => false, 'menu_position' => apply_filters('soliloquy_post_type_menu_position', 248), 'menu_icon' => plugins_url('assets/css/images/menu-icon@2x.png', $this->base->file), 'supports' => array('title'))); // Register the post type with WordPress. register_post_type('soliloquy', $args); }
/** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Load the base class object. $this->base = Soliloquy::get_instance(); // Check for upgrading sliders. add_action('admin_notices', array($this, 'legacy_upgrade')); add_action('admin_notices', array($this, 'legacy_upgrade_success')); // Delete any slider association on attachment deletion. Also delete any extra cropped images. add_action('delete_attachment', array($this, 'delete_slider_association')); add_action('delete_attachment', array($this, 'delete_cropped_image')); // Ensure slider display is correct when trashing/untrashing sliders. add_action('wp_trash_post', array($this, 'trash_slider')); add_action('untrash_post', array($this, 'untrash_slider')); }
/** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Load the base class object. $this->base = Soliloquy::get_instance(); // Remove quick editing from the Soliloquy post type row actions. add_filter('post_row_actions', array($this, 'row_actions'), 10, 2); // Manage post type columns. add_filter('manage_edit-soliloquy_columns', array($this, 'soliloquy_columns')); add_filter('manage_soliloquy_posts_custom_column', array($this, 'soliloquy_custom_columns'), 10, 2); // Update post type messages. add_filter('post_updated_messages', array($this, 'messages')); // Force the menu icon to be scaled to proper size (for Retina displays). add_action('admin_head', array($this, 'menu_icon')); }
/** * Flushes Addon's caches * * @since 2.3.0 */ public function flush_caches($post_id) { // Get instances $instance = Soliloquy_Metaboxes::get_instance(); // Get all Featured Content Sliders $sliders = Soliloquy::get_instance()->get_sliders(); foreach ($sliders as $slider) { // Skip non-FC sliders if ($slider['config']['type'] !== 'fc') { continue; } // Delete transient for this FC slider delete_transient('_sol_fc_' . $slider['id']); } }
/** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Load the base class object. $this->base = Soliloquy::get_instance(); // Load metabox assets. add_action('admin_enqueue_scripts', array($this, 'meta_box_styles')); add_action('admin_enqueue_scripts', array($this, 'meta_box_scripts')); // Load the metabox hooks and filters. add_action('add_meta_boxes', array($this, 'add_meta_boxes'), 100); // Load all tabs. add_action('soliloquy_tab_images', array($this, 'images_tab')); add_action('soliloquy_tab_config', array($this, 'config_tab')); add_action('soliloquy_tab_misc', array($this, 'misc_tab')); // Add action to save metabox config options. add_action('save_post', array($this, 'save_meta_boxes'), 10, 2); }
public function controls() { $found = array(); if (class_exists('Soliloquy')) { $soliloquy_sliders = Soliloquy::get_instance()->get_sliders(); if (is_array($soliloquy_sliders)) { foreach ($soliloquy_sliders as $ss) { if (!isset($ss['id']) && $ss['config']) { continue; } $found[] = array('value' => $ss['id'], 'label' => $ss['config']['title']); } } } if (empty($found)) { $found[] = array('value' => 'none', 'label' => __('No Sliders Available', csl18n()), 'disabled' => true); } $this->addControl('source_id', 'select', __('Select Slider', csl18n()), __('Choose from Soliloquy elements that have already been created.', csl18n()), $found[0]['value'], array('choices' => $found)); }
/** * Primary class constructor. * * @since 1.0.0 * * @param array $config Array of updater config args. */ public function __construct(array $config) { // Load the base class object. $this->base = Soliloquy::get_instance(); // Set class properties. $accepted_args = array('plugin_name', 'plugin_slug', 'plugin_path', 'plugin_url', 'remote_url', 'version', 'key'); foreach ($accepted_args as $arg) { $this->{$arg} = $config[$arg]; } // If the user cannot update plugins, stop processing here. if (!current_user_can('update_plugins')) { return; } global $pagenow; // Only run every 12 hours. $timestamp = get_option('soliloquy_updates_' . $this->plugin_slug); if (!$timestamp) { $timestamp = strtotime('+12 hours'); update_option('soliloquy_updates_' . $this->plugin_slug, $timestamp); } else { $current_timestamp = time(); if ($current_timestamp < $timestamp && 'update-core.php' !== $pagenow && 'update.php' !== $pagenow && !(isset($_GET['tab']) && 'plugin-information' == $_GET['tab'] && isset($_GET['plugin']) && $this->plugin_slug == $_GET['plugin'])) { return; } else { update_option('soliloquy_updates_' . $this->plugin_slug, strtotime('+12 hours')); } } // Load the updater hooks and filters. add_filter('pre_set_site_transient_update_plugins', array($this, 'update_plugins_filter')); add_filter('http_request_args', array($this, 'http_request_args'), 10, 2); add_filter('plugins_api', array($this, 'plugins_api'), 10, 3); }
/** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Load the base class object. $this->base = Soliloquy::get_instance(); // Register the main slider style. $this->stylesheets[] = array('id' => 'soliloquy-style-css', 'href' => add_query_arg('ver', $this->base->version, plugins_url('assets/css/soliloquy.css', $this->base->file))); // Register main slider script. wp_register_script($this->base->plugin_slug . '-script', plugins_url('assets/js/min/soliloquy-min.js', $this->base->file), array('jquery'), $this->base->version, true); // Load hooks and filters. add_shortcode('soliloquy', array($this, 'shortcode')); add_filter('widget_text', 'do_shortcode'); }
/** * Outputs the widget form where the user can specify settings. * * @since 1.0.0 * * @param array $instance The input settings for the current widget instance. */ public function form($instance) { // Get all avilable sliders and widget properties. $sliders = Soliloquy::get_instance()->get_sliders(); $title = isset($instance['title']) ? $instance['title'] : ''; $slider_id = isset($instance['soliloquy_id']) ? $instance['soliloquy_id'] : false; do_action('soliloquy_widget_before_form', $instance); ?> <p> <label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title', 'soliloquy'); ?> </label> <input id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo esc_attr($this->get_field_name('title')); ?> " type="text" value="<?php echo esc_attr($title); ?> " style="width: 100%;" /> </p> <?php do_action('soliloquy_widget_middle_form', $instance); ?> <p> <label for="<?php echo $this->get_field_id('soliloquy_id'); ?> "><?php _e('Slider', 'soliloquy'); ?> </label> <select id="<?php echo esc_attr($this->get_field_id('soliloquy_id')); ?> " name="<?php echo esc_attr($this->get_field_name('soliloquy_id')); ?> " style="width: 100%;"> <?php foreach ($sliders as $slider) { if (!empty($slider['config']['title'])) { $title = $slider['config']['title']; } else { if (!empty($slider['config']['slug'])) { $title = $slider['config']['title']; } else { $title = sprintf(__('Slider ID #%s', 'soliloquy'), $slider['id']); } } echo '<option value="' . $slider['id'] . '"' . selected($slider['id'], $slider_id, false) . '>' . $title . '</option>'; } ?> </select> </p> <?php do_action('soliloquy_widget_after_form', $instance); }
/** * Deactivates a license key entered by the user. * * @since 1.0.0 */ public function deactivate_key() { // Perform a request to deactivate the key. $deactivate = $this->perform_remote_request('deactivate-key', array('tgm-updater-key' => $_POST['soliloquy-license-key'])); // If it returns false, send back a generic error message and return. if (!$deactivate) { $this->errors[] = __('There was an error connecting to the remote key API. Please try again later.', 'soliloquy'); return; } // If an error is returned, set the error and return. if (!empty($deactivate->error)) { $this->errors[] = $deactivate->error; return; } // Otherwise, our request has been done successfully. Reset the option and set the success message. $this->success[] = isset($deactivate->success) ? $deactivate->success : __('Congratulations! You have deactivated the key from this site successfully.', 'soliloquy'); update_option('soliloquy', Soliloquy::default_options()); }
/** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Load the base class object. $this->base = Soliloquy::get_instance(); // Register the main slider style. $this->stylesheets[] = '<link id="soliloquy-style-css" rel="stylesheet" type="text/css" href="' . add_query_arg('ver', $this->base->version, plugins_url('assets/css/soliloquy.css', $this->base->file)) . '" media="all" />'; // Register main slider script. $name = defined('WP_DEBUG') && WP_DEBUG || defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? 'soliloquy-dev-holder.js' : 'soliloquy.js'; wp_register_script($this->base->plugin_slug . '-script', plugins_url('assets/js/' . $name, $this->base->file), array('jquery'), $this->base->version, true); // Load hooks and filters. add_shortcode('soliloquy', array($this, 'shortcode')); add_filter('widget_text', 'do_shortcode'); }
/** * Loads the plugin into WordPress. * * @since 2.1.9 */ public function init() { // Display a notice if Soliloquy does not meet the proper version to run the addon. if (version_compare(Soliloquy::get_instance()->version, '2.0.2', '<')) { add_action('admin_notices', array($this, 'version_notice')); return; } // Load admin only components. if (is_admin()) { $this->require_admin(); } // Load global components. $this->require_global(); // Load the updater add_action('soliloquy_updater', array($this, 'updater')); }
/** * Flushes the Featured Content data caches globally on save/update of any post. * * @since 1.0.0 * * @param int $post_id The current post ID. */ function flush_global_caches($post_id) { // Good to go - let's flush the caches. $sliders = Soliloquy::get_instance()->_get_sliders(); if ($sliders) { foreach ($sliders as $slider) { // Check slider ID exists // Does not exist on slider creation if (!isset($slider['id'])) { continue; } // Delete the ID cache. delete_transient('_sol_cache_' . $slider['id']); delete_transient('_sol_fc_' . $slider['id']); // Delete the slug cache. $slug = get_post_meta($slider['id'], '_sol_slider_data', true); if (!empty($slug['config']['slug'])) { delete_transient('_sol_cache_' . $slug['config']['slug']); delete_transient('_sol_fc_' . $slug['config']['slug']); } } } // Flush the cache for the slider for this post too. $object = get_post($post_id); delete_transient('_sol_cache_' . $post_id); delete_transient('_sol_fc_' . $post_id); if (isset($object->post_name)) { delete_transient('_sol_cache_' . $object->post_name); delete_transient('_sol_fc_' . $object->post_name); } }
/** * Returns the singleton instance of the class. * * @since 1.0.0 * * @return object The Soliloquy object. */ public static function get_instance() { if (!isset(self::$instance) && !self::$instance instanceof Soliloquy) { self::$instance = new Soliloquy(); } return self::$instance; }
/** * Changes the Dynamic Slider to an FC slider if the Dynamic Slider's ID * matches that of a Soliloquy Featured Content Slider * * Also allows the Dynamic Addon shortcode to override configuration settings * for a specific Featured Content Slider * * @param array $data Dynamic Slider Config * @param int $id FC Slider ID * @param array $dynamic_data Slides (will be empty) * @return array Featured Content Slider Config */ public function change_slider_type($data, $id, $dynamic_data) { // Get Soliloquy ID $soliloquy_id = explode('-', $id); $id = $soliloquy_id[1]; // Check ID is an integer if (!is_numeric($id)) { return $data; } // Get Soliloquy Slider $slider_data = apply_filters('soliloquy_dynamic_get_fc_image_data', Soliloquy::get_instance()->get_slider($id), $id); if (!$slider_data) { return $data; } // Replace config options in $slider_data with $data $ignored_config_keys = array('title', 'slug', 'classes', 'type', 'dynamic'); foreach ($data['config'] as $key => $value) { // Skip ignored config keys if (in_array($key, $ignored_config_keys)) { continue; } // Replace $slider_data['config'][$key] // Some FC keys need to be arrays switch ($key) { case 'fc_post_types': case 'fc_terms': case 'fc_inc_ex': // Value needs to be an array $slider_data['config'][$key] = array($data['config'][$key]); break; default: // Value can be anything $slider_data['config'][$key] = $data['config'][$key]; break; } } return $slider_data; }
function tgm_soliloquy_restrict_admin_access() { if (!is_admin()) { return; } if (class_exists('Soliloquy')) { if (!current_user_can('manage_sites')) { remove_action('init', array(Soliloquy::get_instance(), 'init'), 0); remove_action('widgets_init', array(Soliloquy::get_instance(), 'widget')); } } }
/** * Primary class constructor. * * @since 2.0.0 * * @param array $config Array of updater config args. */ public function __construct(array $config) { // Load the base class object. $this->base = Soliloquy::get_instance(); // Set class properties. $accepted_args = array('plugin_name', 'plugin_slug', 'plugin_path', 'plugin_url', 'remote_url', 'version', 'key'); foreach ($accepted_args as $arg) { $this->{$arg} = $config[$arg]; } // If the user cannot update plugins, stop processing here. if (!current_user_can('update_plugins')) { return; } // Load the updater hooks and filters. add_filter('pre_set_site_transient_update_plugins', array($this, 'update_plugins_filter')); add_filter('http_request_args', array($this, 'http_request_args'), 10, 2); add_filter('plugins_api', array($this, 'plugins_api'), 10, 3); }
/** * Grabs JS and executes it for any uninitialised sliders on screen * * Used by soliloquyInitManually() JS function, which in turn is called * by AJAX requests e.g. after an Infinite Scroll event. * * @since 1.0.0 */ function init_sliders() { // Run a security check first. check_ajax_referer('soliloquy-ajax-nonce', 'ajax_nonce'); // Check we have some slider IDs if (!isset($_REQUEST['ids'])) { die; } // Setup instance $instance = Soliloquy_Shortcode::get_instance(); $base = Soliloquy::get_instance(); // Build JS for each slider $js = ''; foreach ($_REQUEST['ids'] as $slider_id) { // Get slider $data = $base->get_slider($slider_id); // If no slider found, skip if (!$data) { if (class_exists('Soliloquy_Dynamic_Common')) { $dynamic_id = Soliloquy_Dynamic_Common::get_instance()->get_dynamic_id(); $defaults = get_post_meta($dynamic_id, '_sol_slider_data', true); $data = $defaults; $data['id'] = 'custom_' . $slider_id; } else { continue; } } } // Output JS echo $js; die; }
/** * Primary class constructor. * * @since 1.0.0 */ public function __construct() { // Load the base class object. $this->base = Soliloquy::get_instance(); }
/** * Legacy sreen helper. Returns the v2 screen helper. * * @since 2.1.1 */ public static function is_soliloquy_add_edit_screen() { return Soliloquy::is_soliloquy_add_edit_screen(); }
/** * Installs an Soliloquy addon. * * @since 1.0.0 */ function soliloquy_ajax_install_addon() { // Run a security check first. check_ajax_referer('soliloquy-install', 'nonce'); // Install the addon. if (isset($_POST['plugin'])) { $download_url = $_POST['plugin']; global $hook_suffix; // Set the current screen to avoid undefined notices. set_current_screen(); // Prepare variables. $method = ''; $url = add_query_arg(array('page' => 'soliloquy-settings'), admin_url('admin.php')); // Start output bufferring to catch the filesystem form if credentials are needed. ob_start(); if (false === ($creds = request_filesystem_credentials($url, $method, false, false, null))) { $form = ob_get_clean(); echo json_encode(array('form' => $form)); die; } // If we are not authenticated, make it happen now. if (!WP_Filesystem($creds)) { ob_start(); request_filesystem_credentials($url, $method, true, false, null); $form = ob_get_clean(); echo json_encode(array('form' => $form)); die; } // We do not need any extra credentials if we have gotten this far, so let's install the plugin. require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; require_once plugin_dir_path(Soliloquy::get_instance()->file) . 'includes/admin/skin.php'; // Create the plugin upgrader with our custom skin. $installer = new Plugin_Upgrader($skin = new Soliloquy_Skin()); $installer->install($download_url); // Flush the cache and return the newly installed plugin basename. wp_cache_flush(); if ($installer->plugin_info()) { $plugin_basename = $installer->plugin_info(); echo json_encode(array('plugin' => $plugin_basename)); die; } } // Send back a response. echo json_encode(true); die; }
/** * Grabs JS and executes it for any uninitialised sliders on screen * * Used by soliloquyInitManually() JS function, which in turn is called * by AJAX requests e.g. after an Infinite Scroll event. * * @since 1.0.0 */ function soliloquy_ajax_init_sliders() { // Run a security check first. check_ajax_referer('soliloquy-ajax-nonce', 'ajax_nonce'); // Check we have some slider IDs if (!isset($_REQUEST['ids'])) { die; } // Setup instance $instance = Soliloquy_Shortcode::get_instance(); $base = Soliloquy::get_instance(); // Build JS for each slider $js = ''; foreach ($_REQUEST['ids'] as $slider_id) { // Get slider $data = $base->get_slider($slider_id); // If no slider found, skip if (!$data) { continue; } // Build JS for this slider $js .= $instance->slider_init_single($data, true); } // Output JS echo $js; die; }