示例#1
0
 function initalize_theme()
 {
     $pages = array(OP_SN, OP_SN . '-setup-wizard');
     $reinit_theme = $reinit_page_theme = false;
     $disable_theme = false;
     if (isset($_GET['page'])) {
         if ($_GET['page'] == OP_SN || $_GET['page'] == OP_SN . '-setup-wizard') {
             $cur = op_get_option('theme', 'dir');
             if (isset($_GET['theme_switch']) && $_GET['theme_switch'] != $cur && ($conf = op_load_theme_config($_GET['theme_switch'])) !== false) {
                 $theme = array('name' => $conf['name'], 'screenshot' => $conf['screenshot'], 'screenshot_thumbnail' => $conf['screenshot_thumbnail'], 'description' => $conf['description'], 'dir' => $_GET['theme_switch']);
                 op_update_option('theme', $theme);
                 $reinit_theme = true;
             }
         } elseif ($_GET['page'] == OP_SN . '-page-builder') {
             $disable_theme = true;
         }
     } elseif (defined('DOING_AJAX')) {
         $action = '';
         if (!($action = op_get('action'))) {
             $action = op_post('action');
         }
         $chk = OP_SN . '-live-editor';
         if (is_string($action) && substr($action, 0, strlen($chk)) == $chk) {
             $disable_theme = true;
         }
     }
     if ($disable_theme === false) {
         op_init_theme();
         define('OP_REINIT_THEME', $reinit_theme);
         if ($reinit_theme) {
             define('OP_SHOW_THEME_MSG', $cur !== false);
             do_action(OP_SN . '-reinit_theme');
         }
     }
 }
 function op_allow_bbforum()
 {
     $forumPage = get_post(url_to_postid("http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']));
     if ($forumPage->post_type == 'forum') {
         op_update_option('blog_enabled', 'Y');
         op_update_option('installed', 'Y');
     }
 }
 /**
  * Save form data
  * @param  array $data
  * @return void
  */
 public function saveTheme($data)
 {
     // Frontend
     op_update_option('op_external_theme_css', op_get_var($data, 'external_theme_css'));
     op_update_option('op_external_theme_js', op_get_var($data, 'external_theme_js'));
     // Backend
     op_update_option('op_le_external_theme_css', op_get_var($data, 'le_external_theme_css'));
     op_update_option('op_le_external_theme_js', op_get_var($data, 'le_external_theme_js'));
 }
示例#4
0
 /**
  * Authorizes user on GoToWebinar using OAuth
  *
  * User will be redirected to GoToWebinar website for authorization
  *
  * @return void
  */
 public function authorize()
 {
     /*
      * If 'callback' is defined we are returned from GoToWebinar with auth details
      */
     if (false === op_get('disconnect')) {
         op_update_option(self::OPTION_NAME_ENABLED, true);
         header("HTTP/1.1 200 OK");
         header('Location: ' . admin_url() . 'admin.php?page=optimizepress#email_marketing_services--oneshoppingcart');
         exit;
     } else {
         if ('1' == op_get('disconnect')) {
             op_delete_option(self::OPTION_NAME_ENABLED);
             header("HTTP/1.1 200 OK");
             header('Location: ' . admin_url() . 'admin.php?page=optimizepress#email_marketing_services--oneshoppingcart');
             exit;
         }
     }
 }
示例#5
0
 function save_social_integration($op)
 {
     if ($social_integration = op_get_var($op, 'social_integration')) {
         op_update_option('social_integration', $social_integration);
     }
 }
示例#6
0
 function save_typography($op)
 {
     if (isset($op['typography'])) {
         $op = $op['typography'];
         $typography = op_get_option('typography');
         $typography = is_array($typography) ? $typography : array();
         $typography_elements = op_typography_elements();
         $typography['font_elements'] = op_get_var($typography, 'font_elements', array());
         $typography['color_elements'] = op_get_var($typography, 'font_elements', array());
         if (isset($typography_elements['font_elements'])) {
             foreach ($typography_elements['font_elements'] as $name => $options) {
                 $tmp = op_get_var($op, $name, op_get_var($typography['font_elements'], $name, array()));
                 $typography['font_elements'][$name] = array('size' => op_get_var($tmp, 'size'), 'font' => op_get_var($tmp, 'font'), 'style' => op_get_var($tmp, 'style'), 'color' => op_get_var($tmp, 'color'));
             }
         }
         if (isset($typography_elements['color_elements'])) {
             foreach ($typography_elements['color_elements'] as $name => $options) {
                 $typography['color_elements'][$name] = op_get_var($op, $name, op_get_var($typography['color_elements'], $name, array()));
             }
         }
         op_update_option('typography', $typography);
     }
 }
示例#7
0
 function save_flowplayer_license($op)
 {
     if (empty($op['flowplayer_license']['custom_logo']) && empty($op['flowplayer_license']['license_key']) && empty($op['flowplayer_license']['js_file']) && empty($op['flowplayer_license']['swf_file'])) {
         /*
          * If every param is empty, we aren't trying to license flowplayer
          */
         op_delete_option('flowplayer_license');
         return;
     } else {
         if (empty($op['flowplayer_license']['license_key']) || empty($op['flowplayer_license']['js_file']) || empty($op['flowplayer_license']['swf_file'])) {
             op_group_error('global_settings');
             op_section_error('global_settings_flowplayer_license');
             op_tpl_error('op_sections_flowplayer_license', __('To remove Flowplayer watermark and/or to use custom logo, license key, HTML5 and Flash commercial version files needs to be present.', OP_SN));
         }
     }
     op_update_option('flowplayer_license', $op['flowplayer_license']);
 }
示例#8
0
 /**
  * Ping SL service with API key
  * @param string $type
  * @param string $version
  * @return bool|WP_Error
  */
 public function ping($type = null, $version = null)
 {
     $args = array('headers' => array(self::HEADER_INSTALLATION_URL_PARAM => $this->getInstallationUrl(), self::HEADER_API_KEY_PARAM => $this->getApiKey()), 'body' => array('type' => $type !== null ? $type : OP_TYPE, 'version' => $version !== null ? $version : OP_VERSION, 'php' => phpversion(), 'locale' => get_locale()));
     if ($type === null && OP_TYPE === 'plugin') {
         $theme = wp_get_theme();
         $args['body']['theme'] = $theme->get('Name');
     } else {
         if ($type === null && OP_TYPE === 'theme') {
             $themeNum = op_get_option('theme', 'dir');
             // There is no theme selected cause the blog setup wasn't finished
             if (empty($themeNum)) {
                 $themeNum = '0 (not selected)';
             }
             $args['body']['theme'] = 'OptimizePress #' . $themeNum;
         }
     }
     $args['body']['optin_stats_current'] = op_optin_stats_get_local_month_count('current');
     $args['body']['optin_stats_last'] = op_optin_stats_get_local_month_count('last');
     $response = wp_remote_post(base64_decode(self::OP_SL_BASE_URL) . 'ping', $args);
     if (is_wp_error($response)) {
         /*
          * Request failed
          */
         $this->log('OP SL error: ' . $response->get_error_message());
         return new WP_Error($response->get_error_code(), $response->get_error_message());
     } else {
         if ((int) $response['response']['code'] !== 200) {
             /*
              * API key issues
              */
             $data = json_decode($response['body']);
             $this->log('OP SL error: ' . $data->error);
             return new WP_Error('invalid', $data->error);
         } else {
             /*
              * Success
              */
             $data = json_decode($response['body']);
             // If SL customer data exists we'll save it
             if (isset($data->data->customer)) {
                 op_update_option('sl_customer', (array) $data->data->customer);
             }
             // If global optin stats exists we'll save it
             if (isset($data->data->optin_stats)) {
                 op_optin_stats_save_global_data($data->data->optin_stats);
             }
             return true;
         }
     }
 }
示例#9
0
 function save_footer_prefs($op)
 {
     $op = op_get_var($op, 'footer_prefs', array());
     $footer_prefs = $this->_footer_prefs();
     $new_footer_prefs = op_get_option('footer_prefs');
     $new_footer_prefs = is_array($new_footer_prefs) ? $new_footer_prefs : array();
     if (isset($footer_prefs['columns'])) {
         $cols = $footer_prefs['columns'];
         $new_footer_prefs['widths'] = array();
         $value = op_get_var($op, 'value', $cols['min']);
         if ($value < $cols['min']) {
             $value = $cols['min'];
         }
         if ($value > $cols['max']) {
             $value = $cols['max'];
         }
         $new_footer_prefs['value'] = $value;
         $max = $cols['max'] + 1;
         $widths = op_get_var($op, 'widths', array());
         for ($i = 1; $i < $max; $i++) {
             $new_footer_prefs['widths'][$i] = op_get_var($widths, $i, 0);
         }
     }
     op_update_option('footer_prefs', $new_footer_prefs);
 }
示例#10
0
 function save_theme()
 {
     if (isset($_POST['theme_id'])) {
         if (op_get_option('theme', 'dir') != $_POST['theme_id'] && ($conf = op_load_theme_config($_POST['theme_id'])) !== false) {
             op_update_option('theme', 'dir', $_POST['theme_id']);
             wp_redirect(menu_page_url(OP_SN . '-theme-settings', false) . '&theme_switch=' . $_POST['theme_id']);
         }
     }
 }
 function save_ontraport($op)
 {
     $appId = op_get_var($op['email_marketing_services'], 'ontraport_app_id');
     $apiKey = op_get_var($op['email_marketing_services'], 'ontraport_api_key');
     if ($appId) {
         op_update_option('ontraport_app_id', $appId);
     } else {
         op_delete_option('ontraport_app_id');
     }
     if ($apiKey) {
         op_update_option('ontraport_api_key', $apiKey);
     } else {
         op_delete_option('ontraport_api_key');
     }
 }
示例#12
0
 function save_step_4()
 {
     $this->save_step(false);
     if (!op_has_error()) {
         op_update_option('blog_enabled', 'Y');
         wp_redirect(menu_page_url(OP_SN . '-setup-wizard', false) . '&step=5');
     }
 }
示例#13
0
 /**
  * Save global optin stats.
  *
  * @param mixed $data
  * @return boolean
  */
 public function saveGlobalData($data)
 {
     op_update_option(self::OPTION_GLOBAL_KEY, (array) $data);
     $this->globalData = (array) $data;
     return true;
 }
 function save_officeautopilot($op)
 {
     $appId = op_get_var($op['email_marketing_services'], 'officeautopilot_app_id');
     $apiKey = op_get_var($op['email_marketing_services'], 'officeautopilot_api_key');
     if ($appId && $apiKey) {
         op_update_option('officeautopilot_app_id', $appId);
         op_update_option('officeautopilot_api_key', $apiKey);
     }
 }
 function save_analytics_and_tracking($op)
 {
     if ($analytics_and_tracking = op_get_var($op, 'analytics_and_tracking')) {
         op_update_option('analytics_and_tracking', $analytics_and_tracking);
     }
 }
 function op_update_trim_option($name, $value)
 {
     op_update_option($name, preg_replace("/\\s+/", '', $value));
 }
示例#17
0
 /**
  * Authorizes user on AWeber using OAuth
  *
  * User will be redirected to AWeber website for authorization
  *
  * @return void
  */
 public function authorize()
 {
     /*
      * If 'callback' is defined we are returned from AWeber with auth details
      */
     if (false === op_get('callback') && false === op_get('disconnect')) {
         /*
          * Defining callback URL where AWeber will return with auth information
          */
         $callbackUrl = site_url('/' . OP_AWEBER_AUTH_URL . '?callback=1');
         /*
          * Fetching request token from AWeber
          */
         list($requestToken, $requestTokenSecret) = $this->getClient()->getRequestToken($callbackUrl);
         /*
          * Saving temp request token secret
          */
         op_update_option(self::OPTION_NAME_OAUTH_ACCESS_SECRET, $requestTokenSecret);
         /*
          * Redirecting to AWeber login/authorization dialog
          */
         header("HTTP/1.1 200 OK");
         header('Location: ' . $this->getClient()->getAuthorizeUrl());
         exit;
     } else {
         if ('1' == op_get('disconnect')) {
             /*
              * Saving access data
              */
             op_delete_option(self::OPTION_NAME_OAUTH_ACCESS_TOKEN);
             op_delete_option(self::OPTION_NAME_OAUTH_ACCESS_SECRET);
             /*
              * Redirecting user to dashboard page
              */
             header("HTTP/1.1 200 OK");
             header('Location: ' . admin_url() . 'admin.php?page=optimizepress#email_marketing_services--aweber');
             exit;
         } else {
             /*
              * Filling AWeber user with needed information (from GET and from data received in earlier step)
              */
             $this->getClient()->user->tokenSecret = op_get_option(self::OPTION_NAME_OAUTH_ACCESS_SECRET);
             $this->getClient()->user->requestToken = op_get('oauth_token');
             $this->getClient()->user->verifier = op_get('oauth_verifier');
             /*
              * Fetching access token
              */
             list($accessToken, $accessTokenSecret) = $this->getClient()->getAccessToken();
             /*
              * Saving access data
              */
             op_update_option(self::OPTION_NAME_OAUTH_ACCESS_TOKEN, $accessToken);
             op_update_option(self::OPTION_NAME_OAUTH_ACCESS_SECRET, $accessTokenSecret);
             /*
              * Redirecting user to dashboard page
              */
             header("HTTP/1.1 200 OK");
             header('Location: ' . admin_url() . 'admin.php?page=optimizepress#email_marketing_services--aweber');
             exit;
         }
     }
 }
示例#18
0
 /**
  * Authorizes user on GoToWebinar using OAuth
  *
  * User will be redirected to GoToWebinar website for authorization
  *
  * @return void
  */
 public function authorize()
 {
     /*
      * If 'callback' is defined we are returned from GoToWebinar with auth details
      */
     if (false === op_get('authorize') && false === op_get('disconnect') && false === op_get('clean')) {
         /*
          * Defining callback URL where GoToWebinar will return with auth information
          */
         $callbackUrl = admin_url('admin.php?action=' . OP_GOTOWEBINAR_AUTH_URL);
         $response = $this->getClient()->getOAuthToken($this->apiKey, $callbackUrl);
         if (is_string($response)) {
             $data = json_decode($response);
             /*
              * Saving access token
              */
             op_update_option(self::OPTION_NAME_OAUTH_ACCESS_TOKEN, $data->access_token);
             op_update_option(self::OPTION_NAME_OAUTH_ORGANIZER_KEY, $data->organizer_key);
             op_update_option(self::OPTION_NAME_OAUTH_EXPIRES_IN, time() + (int) $data->expires_in);
         }
         /*
          * Redirecting to GoToWebinar login/authorization dialog
          */
         header("HTTP/1.1 200 OK");
         header('Location: ' . admin_url() . 'admin.php?page=optimizepress#email_marketing_services--gotowebinar');
         exit;
     } else {
         if ('1' == op_get('disconnect')) {
             /*
              * Saving access data
              */
             op_delete_option(self::OPTION_NAME_OAUTH_ACCESS_TOKEN);
             op_delete_option(self::OPTION_NAME_OAUTH_ORGANIZER_KEY);
             op_delete_option(self::OPTION_NAME_OAUTH_EXPIRES_IN);
             op_delete_option(self::OPTION_NAME_OAUTH_API_KEY);
             /*
              * Redirecting user to dashboard page
              */
             header("HTTP/1.1 200 OK");
             header('Location: ' . admin_url() . 'admin.php?page=optimizepress#email_marketing_services--gotowebinar');
             exit;
         } else {
             if ('1' == op_get('clean')) {
                 op_delete_option(self::OPTION_NAME_OAUTH_API_KEY);
                 /*
                  * Redirecting user to dashboard page
                  */
                 header("HTTP/1.1 200 OK");
                 header('Location: ' . admin_url() . 'admin.php?page=optimizepress#email_marketing_services--gotowebinar');
                 exit;
             } else {
                 $callbackUrl = admin_url('admin.php?action=' . OP_GOTOWEBINAR_AUTH_URL);
                 $this->getClient()->getOAuthToken($this->apiKey, $callbackUrl);
             }
         }
     }
 }
示例#19
0
 function set_typography_defaults()
 {
     //Get the header preferences
     $default_typography = op_default_option('default_typography');
     if (!empty($default_typography)) {
         //Loop through each of them and set the defaults if not set
         foreach ($default_typography['font_elements'] as $key => $cat) {
             foreach ($cat as $key2 => $pref) {
                 //Check to see if this value is empty so we can set the default, if needed
                 if (empty($pref)) {
                     //Explode the key so we can see which setting this is for
                     $key2_array = explode('_', $key2);
                     //Get the setting by seeing what is the last index of the array
                     $setting = end($key2_array);
                     //Check the last index in the array to see which setting this is for
                     switch ($setting) {
                         case 'font':
                             $default_typography['font_elements'][$key][$key2] = 'Source Sans Pro, sans-serif';
                             break;
                         case 'size':
                             if ($key == 'default') {
                                 $default_typography['font_elements'][$key][$key2] = 15;
                             }
                             break;
                             /*case 'style':
                             			$default_typography['font_elements'][$key][$key2] = OP_FONT_STYLE;
                             			break;
                             		case 'spacing':
                             			$default_typography['font_elements'][$key][$key2] = OP_FONT_SPACING;
                             			break;
                             		case 'shadow':
                             			$default_typography['font_elements'][$key][$key2] = OP_FONT_SHADOW;
                             			break;*/
                         /*case 'style':
                         			$default_typography['font_elements'][$key][$key2] = OP_FONT_STYLE;
                         			break;
                         		case 'spacing':
                         			$default_typography['font_elements'][$key][$key2] = OP_FONT_SPACING;
                         			break;
                         		case 'shadow':
                         			$default_typography['font_elements'][$key][$key2] = OP_FONT_SHADOW;
                         			break;*/
                         case 'color':
                             if ($key == 'default') {
                                 $default_typography['font_elements'][$key][$key2] = '###4';
                             }
                             break;
                     }
                 }
             }
         }
         //Update the default typography settings
         op_update_option('default_typography', $default_typography);
     }
     //Also check the footer defaults
     $site_footer = op_default_option('site_footer');
     //Set the default font family but only if it is not currently set
     $site_footer['font_family'] = !empty($site_footer['font_family']) ? 'Source Sans Pro, sans-serif' : '';
     //Update the default footer font settings
     op_update_option('site_footer', $site_footer);
 }
示例#20
0
 /**
  * Saving API key to WP options table
  * @param string $key
  * @return void
  */
 public function setApiKey($key)
 {
     op_update_option(self::OPTION_API_KEY_PARAM, $key);
 }
示例#21
0
 function save_typography($op)
 {
     if (isset($op['default_typography'])) {
         $op = $op['default_typography'];
         $typography = op_get_option('default_typography');
         $typography = is_array($typography) ? $typography : array();
         $typography_elements = op_typography_elements();
         $typography_elements['color_elements'] = array('footer_text_color' => '', 'footer_link_color' => '', 'footer_link_hover_color' => '', 'feature_text_color' => '', 'feature_link_color' => '', 'feature_link_hover_color' => '');
         $typography['font_elements'] = op_get_var($typography, 'font_elements', array());
         $typography['color_elements'] = op_get_var($typography, 'color_elements', array());
         if (isset($typography_elements['font_elements'])) {
             foreach ($typography_elements['font_elements'] as $name => $options) {
                 $tmp = op_get_var($op, $name, op_get_var($typography['font_elements'], $name, array()));
                 $typography['font_elements'][$name] = array('size' => op_get_var($tmp, 'size'), 'font' => op_get_var($tmp, 'font'), 'style' => op_get_var($tmp, 'style'), 'color' => op_get_var($tmp, 'color'));
             }
         }
         if (isset($typography_elements['color_elements'])) {
             foreach ($typography_elements['color_elements'] as $name => $options) {
                 $typography['color_elements'][$name] = $op[$name];
             }
         }
         op_update_option('default_typography', $typography);
         //Check for blanks so we can set the defaults.
         //Otherwise a refresh would be necessary to see the defaults.
         // op_set_font_defaults();
     }
 }