function x_soliloquy_remove_license_functionality()
 {
     if (is_admin()) {
         //
         // 1. Remove the settings menu.
         // 2. Remove license notices.
         //
         remove_action('admin_menu', array(Soliloquy_Settings::get_instance(), 'admin_menu'));
         // 1
         remove_action('admin_notices', array(Soliloquy_License::get_instance(), 'notices'));
         // 2
     }
 }
예제 #2
0
 /**
  * Pings the remote server for addons data.
  *
  * @since 1.0.0
  *
  * @param string $key The user license key.
  * @return bool|array False if no key or failure, array of addon data otherwise.
  */
 public function get_addons_data($key)
 {
     $addons = Soliloquy_License::get_instance()->perform_remote_request('get-addons-data', array('tgm-updater-key' => $key));
     // If there was an API error, set transient for only 10 minutes.
     if (!$addons) {
         set_transient('_sol_addons', false, 10 * MINUTE_IN_SECONDS);
         return false;
     }
     // If there was an error retrieving the addons, set the error.
     if (isset($addons->error)) {
         set_transient('_sol_addons', false, 10 * MINUTE_IN_SECONDS);
         return false;
     }
     // Otherwise, our request worked. Save the data and return it.
     set_transient('_sol_addons', $addons, DAY_IN_SECONDS);
     return $addons;
 }
예제 #3
0
 /**
  * Returns the singleton instance of the class.
  *
  * @since 1.0.0
  *
  * @return object The Soliloquy_License object.
  */
 public static function get_instance()
 {
     if (!isset(self::$instance) && !self::$instance instanceof Soliloquy_License) {
         self::$instance = new Soliloquy_License();
     }
     return self::$instance;
 }
예제 #4
0
파일: ajax.php 프로젝트: jkhedani/ccsa
/**
 * Upgrades sliders from v1 to v2. This also upgrades any current v2 users to the
 * proper post type. This is a mess and it was my fault. :-( I apologize to my customers
 * for making this so rough. You deserve better, and I will work hard to do better by
 * you! Thanks for hanging in there faithfully with me!
 *
 * @since 1.0.0
 */
function soliloquy_ajax_upgrade_sliders()
{
    // Run a security check first.
    check_ajax_referer('soliloquy-upgrade', 'nonce');
    // Increase the time limit to account for large slider sets and suspend cache invalidations.
    set_time_limit(Soliloquy_Common::get_instance()->get_max_execution_time());
    wp_suspend_cache_invalidation(true);
    // Update the license key from v1 to v2 if necessary.
    $v2_license = get_option('soliloquy');
    if (!$v2_license || empty($v2_license['key']) || empty($v2_license['type'])) {
        $v1_license = get_option('soliloquy_license_key');
        $new_license = Soliloquy::default_options();
        if (!empty($v1_license['license'])) {
            $new_license['key'] = $v1_license['license'];
        }
        update_option('soliloquy', $new_license);
        // Force the new key to be validated.
        Soliloquy_License::get_instance()->validate_key(true);
    }
    // Grab all sliders from v1 and convert them to the new system.
    $sliders = get_posts(array('post_type' => 'soliloquy', 'posts_per_page' => -1));
    // Loop through sliders and convert them.
    foreach ((array) $sliders as $slider) {
        // Grab meta from the v1 and v2 sliders.
        $meta = get_post_meta($slider->ID, '_soliloquy_settings', true);
        $v2_meta = get_post_meta($slider->ID, '_sol_slider_data', true);
        // Move meta from v1 to v2, or if already using v2, use v2 as a starting point.
        if (empty($v2_meta)) {
            $new_meta = array('id' => $slider->ID, 'config' => array(), 'slider' => array(), 'status' => 'active');
        } else {
            $new_meta = $v2_meta;
        }
        // Splice meta from v1 to v2.
        if (!empty($new_meta['config']['gutter'])) {
            $new_meta['config']['gutter'] = 0;
        }
        if (!empty($new_meta['config']['position'])) {
            $new_meta['config']['position'] = 'none';
        }
        if (!empty($new_meta['config']['mobile'])) {
            $new_meta['config']['mobile'] = 0;
        }
        $new_meta['config']['title'] = $slider->post_title;
        $new_meta['config']['slug'] = $slider->post_name;
        if (!empty($meta['width'])) {
            $new_meta['config']['slider_width'] = absint($meta['width']);
        }
        if (!empty($meta['height'])) {
            $new_meta['config']['slider_height'] = absint($meta['height']);
        }
        if (!empty($meta['default']) && 'cropped' !== $meta['default']) {
            $new_meta['config']['slider'] = 0;
        }
        if (!empty($meta['custom'])) {
            if ($meta['custom']) {
                if ('full' == $meta['custom']) {
                    $new_meta['config']['slider_size'] = 'default';
                } else {
                    $new_meta['config']['slider_size'] = $meta['custom'];
                    global $_wp_additional_image_sizes;
                    if (isset($_wp_additional_image_sizes[$meta['custom']])) {
                        $width = absint($_wp_additional_image_sizes[$meta['custom']]['width']);
                        $height = absint($_wp_additional_image_sizes[$meta['custom']]['height']);
                    } else {
                        $width = absint(get_option($meta['custom'] . '_size_w'));
                        $height = absint(get_option($meta['custom'] . '_size_h'));
                    }
                    if ($width) {
                        $new_meta['config']['slider_width'] = $width;
                    }
                    if ($height) {
                        $new_meta['config']['slider_height'] = $height;
                    }
                }
            }
        }
        if (!empty($meta['transition'])) {
            if ('slide-horizontal' == $meta['transition']) {
                $new_meta['config']['transition'] = 'horizontal';
            } else {
                if ('slide-vertical' == $meta['transition']) {
                    $new_meta['config']['transition'] = 'vertical';
                } else {
                    $new_meta['config']['transition'] = 'fade';
                }
            }
        }
        if (!empty($meta['speed'])) {
            $new_meta['config']['duration'] = $meta['speed'];
        }
        if (!empty($meta['duration'])) {
            $new_meta['config']['speed'] = $meta['duration'];
        }
        if (!empty($meta['animate'])) {
            $new_meta['config']['auto'] = $meta['animate'];
        }
        if (!empty($meta['navigation'])) {
            $new_meta['config']['arrows'] = $meta['navigation'] ? 1 : 0;
        } else {
            $new_meta['config']['arrows'] = 0;
        }
        if (!empty($meta['control'])) {
            $new_meta['config']['control'] = $meta['control'] ? 1 : 0;
        } else {
            $new_meta['config']['control'] = 0;
        }
        if (!empty($meta['keyboard'])) {
            $new_meta['config']['keyboard'] = $meta['keyboard'];
        }
        if (!empty($meta['pauseplay'])) {
            $new_meta['config']['pauseplay'] = $meta['pauseplay'];
        }
        if (!empty($meta['random'])) {
            $new_meta['config']['random'] = $meta['random'];
        }
        if (!empty($meta['number'])) {
            $new_meta['config']['start'] = $meta['number'];
        }
        if (!empty($meta['loop'])) {
            $new_meta['config']['loop'] = $meta['loop'];
        }
        if (!empty($meta['hover'])) {
            $new_meta['config']['hover'] = $meta['hover'];
        }
        if (!empty($meta['css'])) {
            $new_meta['config']['css'] = $meta['css'];
        }
        if (!empty($meta['smooth'])) {
            $new_meta['config']['smooth'] = $meta['smooth'];
        }
        if (!empty($meta['delay'])) {
            $new_meta['config']['delay'] = $meta['delay'];
        }
        // Set to the classic theme to keep people from going nuts with a theme change.
        if (!empty($meta['theme']) && 'metro' == $meta['theme']) {
            $new_meta['config']['slider_theme'] = 'metro';
        } else {
            $new_meta['config']['slider_theme'] = 'classic';
        }
        // Grab all attachments and add them to the slider.
        $attachments = get_posts(array('orderby' => 'menu_order', 'order' => 'ASC', 'post_type' => 'attachment', 'post_parent' => $slider->ID, 'post_status' => null, 'posts_per_page' => -1));
        // Loop through attachments and add them to the slider.
        foreach ((array) $attachments as $slide) {
            switch ($slide->post_mime_type) {
                case 'soliloquy/video':
                    $new_meta['slider'][$slide->ID] = array('status' => 'active', 'id' => $slide->ID, 'src' => '', 'title' => isset($slide->post_title) ? $slide->post_title : '', 'link' => '', 'url' => isset($slide->post_content) ? $slide->post_content : '', 'thumb' => '', 'caption' => isset($slide->post_excerpt) ? $slide->post_excerpt : '', 'type' => 'video');
                    break;
                case 'soliloquy/html':
                    $new_meta['slider'][$slide->ID] = array('status' => 'active', 'id' => $slide->ID, 'src' => '', 'title' => isset($slide->post_title) ? $slide->post_title : '', 'link' => '', 'code' => isset($slide->post_content) ? $slide->post_content : '', 'type' => 'html');
                    break;
                default:
                    $url = wp_get_attachment_image_src($slide->ID, 'full');
                    $alt_text = get_post_meta($slide->ID, '_wp_attachment_image_alt', true);
                    $new_meta['slider'][$slide->ID] = array('status' => 'active', 'id' => $slide->ID, 'src' => isset($url[0]) ? esc_url($url[0]) : '', 'title' => get_the_title($slide->ID), 'link' => get_post_meta($slide->ID, '_soliloquy_image_link', true), 'linktab' => get_post_meta($slider->ID, '_soliloquy_image_link_tab', true), 'alt' => !empty($alt_text) ? $alt_text : get_the_title($slide->ID), 'caption' => !empty($slide->post_excerpt) ? $slide->post_excerpt : '', 'filter' => get_post_meta($slide->ID, '_soliloquy_filters_image_filter', true), 'type' => 'image');
                    break;
            }
        }
        // Convert v1 Pinterest addon data to v2 if necessary.
        $pinterest = get_post_meta($slider->ID, '_soliloquy_pinterest', true);
        if (!empty($pinterest['enable'])) {
            $new_meta['config']['pinterest'] = $pinterest['enable'];
        }
        if (!empty($pinterest['position'])) {
            $new_meta['config']['pinterest_position'] = str_replace('-', '_', $pinterest['position']);
        }
        // Convert v1 carousel addon to v2 if necessary.
        $carousel = get_post_meta($slider->ID, '_soliloquy_carousel', true);
        if (!empty($carousel['width'])) {
            $new_meta['config']['carousel'] = 1;
            $new_meta['config']['carousel_width'] = $carousel['width'];
        }
        if (!empty($carousel['margin'])) {
            $new_meta['config']['carousel_margin'] = $carousel['margin'];
        }
        if (!empty($carousel['mminimum'])) {
            $new_meta['config']['carousel_min'] = $carousel['minimum'];
        }
        if (!empty($carousel['maximum'])) {
            $new_meta['config']['carousel_maximum'] = $carousel['maximum'];
        }
        if (!empty($carousel['move'])) {
            $new_meta['config']['carousel_move'] = $carousel['move'];
        }
        // Convert v1 thumbnails addon to v2 if necessary.
        $thumbnails = get_post_meta($slider->ID, '_soliloquy_thumbnails', true);
        if (!empty($thumbnails['use'])) {
            $new_meta['config']['thumbnails'] = $thumbnails['use'];
        }
        if (!empty($thumbnails['width'])) {
            $new_meta['config']['thumbnails_width'] = $thumbnails['width'];
        }
        if (!empty($thumbnails['margin'])) {
            $new_meta['config']['thumbnails_margin'] = $thumbnails['margin'];
        }
        if (!empty($thumbnails['minimum'])) {
            $new_meta['config']['thumbnails_num'] = $thumbnails['minimum'];
        }
        if (!empty($thumbnails['position'])) {
            $new_meta['config']['thumbnails_position'] = $thumbnails['position'];
        }
        // Convert v1 featured content to v 2 if necessary.
        $fc = get_post_meta($slider->ID, '_soliloquy_fc', true);
        if (!empty($meta['type']) && 'featured' == $meta['type']) {
            $new_meta['config']['type'] = 'fc';
        }
        if (!empty($fc['post_types'])) {
            $new_meta['config']['fc_post_types'] = $fc['post_types'];
        }
        if (!empty($fc['terms'])) {
            $new_meta['config']['fc_terms'] = $fc['terms'];
        }
        if (!empty($fc['query'])) {
            $new_meta['config']['fc_query'] = $fc['query'];
        }
        if (!empty($fc['include_exclude'])) {
            $new_meta['config']['fc_inc_ex'] = $fc['include_exclude'];
        }
        if (!empty($fc['orderby'])) {
            $new_meta['config']['fc_orderby'] = $fc['orderby'];
        }
        if (!empty($fc['order'])) {
            $new_meta['config']['fc_order'] = $fc['order'];
        }
        if (!empty($fc['number'])) {
            $new_meta['config']['fc_number'] = $fc['number'];
        }
        if (!empty($fc['offset'])) {
            $new_meta['config']['fc_offset'] = $fc['offset'];
        }
        if (!empty($fc['post_status'])) {
            $new_meta['config']['fc_status'] = $fc['post_status'];
        }
        if (!empty($fc['post_url'])) {
            $new_meta['config']['fc_post_url'] = $fc['post_url'];
        }
        if (!empty($fc['post_title'])) {
            $new_meta['config']['fc_post_title'] = $fc['post_title'];
        }
        if (!empty($fc['post_title_link'])) {
            $new_meta['config']['fc_post_title_link'] = $fc['post_title_link'];
        }
        if (!empty($fc['content_type'])) {
            $new_meta['config']['fc_content_type'] = str_replace('-', '_', $fc['content_type']);
        }
        if (!empty($fc['post_content_length'])) {
            $new_meta['config']['fc_content_length'] = $fc['post_content_length'];
        }
        if (!empty($fc['ellipses'])) {
            $new_meta['config']['fc_content_ellipses'] = $fc['ellipses'];
        }
        if (!empty($fc['read_more'])) {
            $new_meta['config']['fc_read_more'] = $fc['read_more'];
        }
        if (!empty($fc['read_more_text'])) {
            $new_meta['config']['fc_read_more_text'] = $fc['read_more_text'];
        }
        if (!empty($fc['fallback'])) {
            $new_meta['config']['fc_fallback'] = $fc['fallback'];
        }
        // Convert v1 Instagram addon to v2 if necessary.
        $instagram = get_post_meta($slider->ID, '_soliloquy_instagram', true);
        // Update the Instagram db option from v1 to v2 if v2 does not already exist.
        $v2_auth = get_option('soliloquy_instagram');
        if (!$v2_auth || empty($v2_auth['token']) || empty($v2_auth['id'])) {
            $v1_auth = get_option('soliloquy_instagram_data');
            $new_auth = array();
            if (!empty($v1_auth->access_token)) {
                $new_auth['token'] = $v1_auth->access_token;
            }
            if (!empty($v1_auth->user->id)) {
                $new_auth['id'] = $v1_auth->user->id;
            }
            update_option('soliloquy_instagram', $new_auth);
        }
        if (!empty($meta['type']) && 'instagram' == $meta['type']) {
            $new_meta['config']['type'] = 'instagram';
        }
        if (!empty($instagram['number'])) {
            $new_meta['config']['instagram_number'] = $instagram['number'];
        }
        if (!empty($instagram['link'])) {
            $new_meta['config']['instagram_link'] = $instagram['link'];
        }
        if (!empty($instagram['caption'])) {
            $new_meta['config']['instagram_caption'] = $instagram['caption'];
        }
        if (!empty($instagram['random'])) {
            $new_meta['config']['instagram_random'] = $instagram['random'];
        }
        if (!empty($instagram['cache'])) {
            $new_meta['config']['instagram_cache'] = $instagram['cache'];
        }
        // Convert v1 lightbox addon to v2 if necessary. This is a new lightbox engine so not a lot of crossover here.
        $lightbox = get_post_meta($slider->ID, '_soliloquy_lightbox', true);
        if (!empty($lightbox['auto'])) {
            $new_meta['config']['lightbox'] = $lightbox['auto'];
        }
        if (!empty($lightbox['lightbox_theme'])) {
            $new_meta['config']['lightbox_theme'] = 'base';
        }
        // Update the post meta for the new slider.
        update_post_meta($slider->ID, '_sol_slider_data', $new_meta);
        // Force the post to update.
        wp_update_post(array('ID' => $slider->ID, 'post_type' => 'soliloquy'));
        // Flush caches for any sliders.
        Soliloquy_Common::get_instance()->flush_slider_caches($slider->ID, $new_meta['config']['slug']);
    }
    // Now grab any v2 sliders and convert the post type back to the proper system.
    $v2_sliders = get_posts(array('post_type' => 'soliloquyv2', 'posts_per_page' => -1));
    // Loop through the sliders, grab the data, delete and backwards convert them back to 'soliloquy' post type.
    foreach ((array) $v2_sliders as $slider) {
        // Grab any slider meta and add the attachment ID to the data array.
        $slider_meta = get_post_meta($slider->ID, '_sol_slider_data', true);
        if (!empty($slider_meta['slider'])) {
            foreach ($slider_meta['slider'] as $id => $data) {
                $slider_meta['slider'][$id]['id'] = $id;
            }
        }
        update_post_meta($slider->ID, '_sol_slider_data', $slider_meta);
        $data = array('ID' => $slider->ID, 'post_type' => 'soliloquy');
        wp_update_post($data);
        // Flush caches for any sliders.
        Soliloquy_Common::get_instance()->flush_slider_caches($slider->ID);
    }
    // Turn off cache suspension and flush the cache to remove any cache inconsistencies.
    wp_suspend_cache_invalidation(false);
    wp_cache_flush();
    // Update the option to signify that upgrading is complete.
    update_option('soliloquy_upgrade', true);
    // Send back the response.
    echo json_encode(true);
    die;
}