function save_meta_box($post_id) { if (!op_can_edit_page($post_id) || !isset($_POST['op_comment_meta_box']) || !wp_verify_nonce($_POST['op_comment_meta_box'], 'op_comment_meta_box')) { return; } $fb = $wp = false; $newcomments = array(); if (($comments = op_post('op', 'comments', 'facebook', 'enabled')) && $comments == 'Y') { $fb = true; } $def = $this->get_option('comments', 'facebook', 'enabled'); if ($def == 'Y' && $fb === false) { $newcomments['facebook'] = 'N'; } elseif ($def != 'Y' && $fb === true) { $newcomments['facebook'] = 'Y'; } if (($comments = op_post('op', 'comments', 'wordpress', 'enabled')) && $comments == 'Y') { $wp = true; } $def = $this->get_option('comments', 'wordpress', 'enabled'); if ($def == 'Y' && $wp === false) { $newcomments['wordpress'] = 'N'; } elseif ($def != 'Y' && $wp === true) { $newcomments['wordpress'] = 'Y'; } if (count($newcomments) > 0) { //echo 'update1 ==== '.$post_id; update_post_meta($post_id, 'op_comments', $newcomments); } else { //echo 'delete'; delete_post_meta($post_id, 'op_comments'); } //exit; }
function op_check_optin_form() { if (isset($_POST['op_optin_form']) && $_POST['op_optin_form'] == 'Y') { $message = ''; $data = unserialize(base64_decode($_POST['op_optin_form_data'])); foreach ($data['fields'] as $field) { $val = isset($_POST[$field['name']]) ? $_POST[$field['name']] : ''; $message .= $field['text'] . ': ' . $val . "\n"; } $message .= "\n"; foreach ($data['extra_fields'] as $name => $text) { $val = isset($_POST[$name]) ? $_POST[$name] : ''; $message .= $text . ': ' . $val . "\n"; } $email = op_post('email'); $webinar = op_post('gotowebinar'); /* * Triggering GoToWebinar */ if (false !== $webinar) { do_action('gotowebinar', $webinar, $email); } wp_mail($data['email_to'], 'Optin Form Submission - ' . op_current_url(), $message); if ($data['redirect_url'] != '') { wp_redirect($data['redirect_url']); exit; } else { $GLOBALS['op_optin_form_sent'] = true; } } }
public function subscribe($data) { if (isset($data['email'])) { $name = op_post('name'); $params = array('FirstName' => false !== $name ? $name : '', 'Email' => $data['email']); $contactId = $this->getClient()->addCon($params); return true; } else { wp_die('Mandatory information not present [email address].'); } }
public function subscribe($data) { if (isset($data['email'])) { $name = op_post('name'); $params = array('FirstName' => false !== $name ? $name : '', 'Email' => $data['email']); try { $this->getClient()->addCon($params); } catch (Exception $e) { error_log('Exception while doing optin: ' . print_r($e->getMessage(), true)); } return true; } else { wp_die('Mandatory information not present [email address].'); } }
function save_page_template($post_id) { if (!op_can_edit_page($post_id) || !isset($_POST['op_page_template']) || !wp_verify_nonce($_POST['op_page_template'], 'op_page_template')) { return; } $remove = true; $cur_tpl = op_default_attr('column_layout', 'option'); if ($tpl = op_post('op_page_tpl_file')) { if ($cur_tpl != $tpl) { update_post_meta($post_id, '_op_page_template', $tpl); $remove = false; } } if ($remove) { delete_post_meta($post_id, '_op_page_template'); } }
function save_meta_box($post_id) { // if(!op_can_edit_page($post_id) || !isset($_POST['op_scripts_meta_box']) || !wp_verify_nonce( $_POST['op_scripts_meta_box'], 'op_scripts_meta_box' ) ){ // return; // } if ($op = op_post('op', 'scripts')) { $positions = op_get_var($op, 'position', array()); $scripts = array(); for ($i = 0, $iteml = count($positions); $i < $iteml; $i++) { $scripts[] = array('position' => $positions[$i], 'script' => stripslashes($op['script'][$i])); } if (count($scripts) > 0) { update_post_meta($post_id, '_' . OP_SN . '_scripts', $scripts); } else { delete_post_meta($post_id, '_' . OP_SN . '_scripts'); } } }
public function subscribe($data) { $this->logger->info('Subscribing user: '******'email'])) { $name = op_post('name'); $params = array('FirstName' => false !== $name ? $name : '', 'Email' => $data['email']); try { $status = $this->getClient()->addCon($params); $this->logger->notice('Subscription status: ' . print_r($status, true)); } catch (Exception $e) { $this->logger->error('Error ' . $e->getCode() . ': ' . $e->getMessage()); } return true; } else { $this->logger->alert('Mandatory information not present [email address]'); wp_die('Mandatory information not present [email address].'); } }
/** * We create a dummy (draft) page that is populated for content preview. */ function content_layout_preview() { global $user_ID; global $wpdb; $page = get_page_by_path('op_content_layout_preview_page'); // Page already exists if (is_object($page)) { $page_id = $page->ID; } else { $page['post_type'] = 'page'; $page['post_content'] = ''; $page['post_parent'] = 0; $page['post_author'] = $user_ID; $page['post_status'] = 'op_preview'; $page['post_title'] = 'OptimizePress Content Preview Page'; $page['post_name'] = 'op_content_layout_preview_page'; $page_id = wp_insert_post($page); /* Add Page Failed */ if ($page_id == 0) { die('Error creating new page.'); } } echo get_permalink($page_id) . '?op-no-admin-bar=true'; define('OP_PAGEBUILDER_ID', $page_id); $template = $_POST['template']; /*$result = $wpdb->get_row($wpdb->prepare( "SELECT `layouts`,`settings`,`guid` FROM `{$wpdb->prefix}optimizepress_predefined_layouts` WHERE `id`=%d ORDER BY name ASC", $template ));*/ $result = $wpdb->get_row($wpdb->prepare("SELECT `layouts`,`settings` FROM `{$wpdb->prefix}optimizepress_predefined_layouts` WHERE `id`=%d ORDER BY name ASC", $template)); $keep = op_post('keep_options'); if (!is_array($keep)) { $keep = array(); } // Set page template ID if it exists - this will be used for stats and analytics /*if (isset($result->guid) && !empty($result->guid)) { op_update_page_option('template_id', $result->guid); }*/ op_update_page_option('pagebuilder', 'Y'); op_page_set_saved_settings($result, $keep); die; }
function folder_list() { $files = array(); $checks = array('image', 'style', 'checkbox'); foreach ($checks as $chk) { if (($folders = op_post('folders', $chk)) && is_array($folders)) { $files[$chk] = $this->_process_files($folders, $chk); } } echo json_encode($files); exit; }
/** * * Saving of membership pages * @param array $conf * @return void */ function save_membership_settings($conf) { global $wpdb; $op = op_post('op'); if (empty($op['pageType']['type'])) { // saving product! update_post_meta(OP_PAGEBUILDER_ID, 'type', 'product'); op_update_page_option('membership', 'layout', $op['page']['preset_option']); // change title and slug $post = array('ID' => OP_PAGEBUILDER_ID, 'post_title' => $op['product']['name'], 'post_name' => sanitize_title($op['product']['name'])); wp_update_post($post); } else { if ($op['pageType']['type'] == 'category') { //$page_id = $this->_add_page($op['category']['name'], OP_PAGEBUILDER_ID, 'category'); $page_id = OP_PAGEBUILDER_ID; wp_update_post(array('ID' => $page_id, 'post_parent' => $op['pageType']['product'], 'post_title' => $op['category']['name'], 'post_name' => sanitize_title($op['category']['name']))); update_post_meta($page_id, 'type', 'category'); update_post_meta($page_id, '_' . OP_SN . '_pagebuilder', 'Y'); $value = array('layout' => $op['page']['preset_option'], 'description' => base64_encode($op['category']['description'])); update_post_meta($page_id, '_' . OP_SN . '_membership', maybe_serialize($value)); $value = array('type' => 'membership', 'dir' => $op['theme']); update_post_meta($page_id, '_' . OP_SN . '_theme', maybe_serialize($value)); } else { if ($op['pageType']['type'] == 'subcategory') { //$page_id = $this->_add_page($op['subcategory']['name'], $op['subcategory']['category'], 'subcategory'); $page_id = OP_PAGEBUILDER_ID; wp_update_post(array('ID' => $page_id, 'post_parent' => $op['subcategory']['category'], 'post_title' => $op['subcategory']['name'], 'post_name' => sanitize_title($op['subcategory']['name']))); update_post_meta($page_id, 'type', 'subcategory'); update_post_meta($page_id, '_' . OP_SN . '_pagebuilder', 'Y'); $value = array('layout' => $op['page']['preset_option'], 'description' => base64_encode($op['subcategory']['description'])); update_post_meta($page_id, '_' . OP_SN . '_membership', maybe_serialize($value)); $value = array('type' => 'membership', 'dir' => $op['theme']); update_post_meta($page_id, '_' . OP_SN . '_theme', maybe_serialize($value)); } else { if ($op['pageType']['type'] == 'content') { if (!empty($op['content']['subcategory'])) { $parentId = $op['content']['subcategory']; } else { if (!empty($op['content']['category'])) { $parentId = $op['content']['category']; } else { if (!empty($op['pageType']['product'])) { $parentId = $op['pageType']['product']; } } } //$page_id = $this->_add_page($op['content']['name'], $parentId, 'content'); $page_id = OP_PAGEBUILDER_ID; wp_update_post(array('ID' => $page_id, 'post_parent' => $parentId, 'post_title' => $op['content']['name'], 'post_name' => sanitize_title($op['content']['name']))); update_post_meta($page_id, 'type', 'content'); update_post_meta($page_id, '_' . OP_SN . '_pagebuilder', 'Y'); $value = array('layout' => $op['page']['preset_option'], 'description' => base64_encode($op['content']['description'])); update_post_meta($page_id, '_' . OP_SN . '_membership', maybe_serialize($value)); $value = array('type' => 'membership', 'dir' => $op['theme']); update_post_meta($page_id, '_' . OP_SN . '_theme', maybe_serialize($value)); } } } } }
/** * Restore page revision * @author Zvonko Biskup <*****@*****.**> * @since 2.1.9 * @return mixed */ function restore_page_revision() { global $wpdb; $table = $wpdb->prefix . 'optimizepress_post_layouts'; $postID = op_post('postID'); $revisionID = op_post('revisionID'); if (empty($postID) || empty($revisionID)) { return 0; exit; } $wpdb->update($table, array('status' => 'revision'), array('post_id' => $postID, 'status' => 'publish')); $sql = "UPDATE " . $table . " SET status='publish', modified=NOW() WHERE post_id = " . $postID . " AND id=" . $revisionID; $wpdb->query($sql); //$wpdb->update($table, array('status' => 'publish'), array('id' => $revisionID)); return 1; exit; }
/** * AJAX calls this function to save membership section of Live editor * @return void */ function save_membership() { global $wpdb; $this->check_nonce(); $this->init_page(); $postId = $wpdb->escape($_POST['page_id']); if (defined("WS_PLUGIN__OPTIMIZEMEMBER_VERSION")) { c_ws_plugin__optimizemember_meta_box_saves::save_meta_boxes($postId); } // saving membership pages options $op = op_post('op'); $current = op_page_option('membership', 'layout'); // this happens only if we have something to save (it is a membership page!) if (!empty($op['pageType']['type']) && $op['pageType']['type'] == 'product') { update_post_meta($op['pageId'], 'type', 'product'); op_update_page_option('membership', 'layout', $op['page']['preset_option']); // change title and slug $post = array('ID' => $op['pageId'], 'post_title' => $op['product']['name'], 'post_name' => sanitize_title($op['product']['name']), 'post_parent' => ''); wp_update_post($post); } if (empty($op['pageType']['type']) && !empty($op) && empty($op['type'])) { // saving product! update_post_meta($op['pageId'], 'type', 'product'); op_update_page_option('membership', 'layout', $op['page']['preset_option']); // change title and slug $post = array('ID' => $op['pageId'], 'post_title' => $op['product']['name'], 'post_name' => sanitize_title($op['product']['name']), 'post_parent' => ''); wp_update_post($post); } else { if ($op['pageType']['type'] == 'category') { $page_id = $op['pageId']; $post = array('ID' => $op['pageId'], 'post_title' => $op['category']['name'], 'post_name' => sanitize_title($op['category']['name']), 'post_parent' => $op['pageType']['product']); wp_update_post($post); $value = array('layout' => $op['page']['preset_option'], 'description' => base64_encode($op['category']['description'])); update_post_meta($page_id, '_' . OP_SN . '_membership', maybe_serialize($value)); $value = array('type' => 'membership', 'dir' => $op['theme']); update_post_meta($page_id, '_' . OP_SN . '_theme', maybe_serialize($value)); } else { if ($op['pageType']['type'] == 'subcategory') { $page_id = $op['pageId']; $post = array('ID' => $op['pageId'], 'post_title' => $op['subcategory']['name'], 'post_name' => sanitize_title($op['subcategory']['name']), 'post_parent' => $op['subcategory']['category']); wp_update_post($post); $value = array('layout' => $op['page']['preset_option'], 'description' => base64_encode($op['subcategory']['description'])); update_post_meta($page_id, '_' . OP_SN . '_membership', maybe_serialize($value)); $value = array('type' => 'membership', 'dir' => $op['theme']); update_post_meta($page_id, '_' . OP_SN . '_theme', maybe_serialize($value)); } else { if ($op['pageType']['type'] == 'content') { if (!empty($op['content']['subcategory'])) { $parentId = $op['content']['subcategory']; } else { if (!empty($op['content']['category'])) { $parentId = $op['content']['category']; } else { $parentId = $op['pageType']['product']; } } $page_id = $op['pageId']; $post = array('ID' => $op['pageId'], 'post_title' => $op['content']['name'], 'post_name' => sanitize_title($op['content']['name']), 'post_parent' => $parentId); wp_update_post($post); $value = array('layout' => $op['page']['preset_option'], 'description' => base64_encode($op['content']['description'])); update_post_meta($page_id, '_' . OP_SN . '_membership', maybe_serialize($value)); $value = array('type' => 'membership', 'dir' => $op['theme']); update_post_meta($page_id, '_' . OP_SN . '_theme', maybe_serialize($value)); } } } if (!empty($op['type'])) { $post = array('ID' => $op['pageId'], 'post_parent' => ''); if ($op['type'] == 'product') { wp_update_post($post); } update_post_meta($op['pageId'], 'type', $op['type']); } } //error_log(OP_PAGEBUILDER_ID); if (!empty($op['typeForChange'])) { $value = array('type' => 'membership', 'dir' => '1'); update_post_meta(OP_PAGEBUILDER_ID, '_' . OP_SN . '_theme', maybe_serialize($value)); update_post_meta(OP_PAGEBUILDER_ID, 'type', $op['typeForChange']); } /* * DAP integration */ if (isset($op['membership']['dap_redirect_url'])) { update_post_meta($postId, 'dap_redirect_url', $op['membership']['dap_redirect_url']); } /* * Fast Member integration */ if (isset($op['membership']['fast_member_redirect_url'])) { update_post_meta($postId, 'fast_member_redirect_url', $op['membership']['fast_member_redirect_url']); } /* * iMember360 integration */ if (isset($op['membership']['imember_redirect_url'])) { update_post_meta($postId, 'imember_redirect_url', $op['membership']['imember_redirect_url']); } echo json_encode(array('done' => true)); exit; }
/** * Processing optin form, subscribing users * @author Luka Peharda <*****@*****.**> * @return void */ function processOptinForm() { global $wp; /* * We are checking for our processing URL slug */ if ($wp->request === 'process-optin-form') { $type = op_post('provider'); /* * Infusionsoft needs to be redirected with 307 to keep all of its required POST vars */ if ($type === 'infusionsoft') { $list = op_post('list'); $email = op_post('inf_field_Email'); $webinar = op_post('gotowebinar'); /* * Triggering GoToWebinar */ if (false !== $webinar) { do_action('gotowebinar', $webinar, $email); } /* * Redirecting user with all its POST data (needed for GoToWebinar interception) */ wp_redirect(op_post('redirect_url'), 307); } else { if (false !== $type) { require_once OP_MOD . 'email/ProviderFactory.php'; $list = op_post('list'); $email = op_post('email'); $webinar = op_post('gotowebinar'); /* * Triggering GoToWebinar */ if (false !== $webinar) { do_action('gotowebinar', $webinar, $email); } $provider = OptimizePress_Modules_Email_ProviderFactory::getFactory($type, true); $provider->subscribe(array('list' => $list, 'email' => $email)); header("HTTP/1.1 200 OK"); header("Location: " . op_post('redirect_url')); } else { $email = op_post(op_post('email_field')); $webinar = op_post('gotowebinar'); /* * Triggering GoToWebinar */ if (false !== $webinar) { do_action('gotowebinar', $webinar, $email); } /* * Redirecting user with all its POST data (needed for GoToWebinar interception) */ wp_redirect(op_post('redirect_url'), 307); } } exit; } }
function _op_file_info($return = false) { $type = op_post('attach_type'); $url = $html = $file = ''; if ($type == 'url') { $url = op_post('media_url'); $ext = preg_match('/\\.([^.]+)$/', $url, $matches) ? strtolower($matches[1]) : false; if (in_array($ext, array('jpg', 'jpeg', 'gif', 'png'))) { $html .= '<a href="' . $url . '" target="_blank" class="preview-image"><img src="' . $url . '" alt="uploaded-image" /></a><a href="#remove" class="remove-file">' . __('Remove Image', OP_SN) . '</a>'; } else { $html .= '<a href="' . $url . '" target="_blank" class="preview-image">' . __('View File', OP_SN) . '</a><a href="#remove" class="remove-file">' . __('Remove File', OP_SN) . '</a>'; } } else { $item_id = op_post('media_item'); $size = op_post('media_size'); $file = get_attached_file($item_id); if (wp_attachment_is_image($item_id)) { $url = wp_get_attachment_image_src($item_id, $size); $html = '<a href="' . $url[0] . '" target="_blank" class="preview-image"><img src="' . $url[0] . '" alt="uploaded-image" /></a><a href="#remove" class="remove-file">' . __('Remove Image', OP_SN) . '</a>'; $url = $url[0]; } else { $url = wp_get_attachment_url($item_id); $html = '<a href="' . $url . '" target="_blank" class="preview-image">' . __('View File', OP_SN) . '</a><a href="#remove" class="remove-file">' . __('Remove File', OP_SN) . '</a>'; } } echo json_encode(array('url' => $url, 'html' => $html, 'file' => $file)); exit; }
/** * Searches for possible form fields from POST and adds them to the collection * @return null|array Null if no value/field found */ protected function prepareMergeVars() { $vars = array(); $allowed = array_keys($this->getCustomFields()); foreach ($allowed as $name) { if ($name !== 'name' && op_post($name) !== false) { $vars[$name] = op_post($name); } } if (count($vars) === 0) { $vars = null; } return $vars; }
function save_launch_suite() { global $wpdb; add_filter(OP_SN . '-script-localize', array($this, 'localize')); $funnel_dropdown = ''; $current = intval(op_get('funnel_id')); $found = false; $funnels = $wpdb->get_results("SELECT id,title FROM `{$wpdb->prefix}optimizepress_launchfunnels` ORDER BY title ASC"); $funnel_count = 0; if ($funnels) { $funnel_count = count($funnels); foreach ($funnels as $funnel) { if ($current < 1) { $current = $funnel->id; $found = true; } elseif ($current == $funnel->id) { $found = true; } $funnel_dropdown .= '<option value="' . $funnel->id . '"' . ($current == $funnel->id ? ' selected="selected"' : '') . '>' . op_attr($funnel->title) . '</option>'; } } $this->funnel_count = $funnel_count; $this->funnel_dropdown = $funnel_dropdown; if ($found) { define('OP_LAUNCH_FUNNEL', $current); } $this->data['settings_sections'] = array('gateway_key' => __('Funnel Gateway Key', OP_SN), 'perpetual_launch' => __('Perpetual/Evergreen Launch Mode', OP_SN), 'redirect_all' => __('Redirect All Launch Pages', OP_SN), 'hide_coming_soon' => __('Hide Coming Soon Placeholders', OP_SN)); $this->data['settings_sections'] = apply_filters('op_launch_suite_settings_sections', $this->data['settings_sections']); if ($found && isset($_POST[OP_SN . '_launch_suite'])) { if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'op_launch_suite')) { $op = op_post('op'); foreach ($this->data['settings_sections'] as $name => $section) { if (is_array($section)) { if (isset($section['save_action'])) { call_user_func($section['save_action'], op_get_var($op, $name)); } } else { call_user_func(array($this, '_save_' . $name), op_get_var($op, $name)); } } $funnel_pages = array('sales' => array(), 'stages' => array()); $used_ids = array(); $page_ids = array('sales' => 0, 'stages' => array()); if (isset($op['funnel_pages'])) { if (isset($op['funnel_pages']['sales'])) { $options = array('page_setup' => array('open_sales_cart', 'sales_page', 'hide_cart'), 'page_thumbnails' => array('active_thumbnail', 'inactive_thumbnail'), 'navigation' => array('active_link_text', 'inactive_link_text')); if (isset($op['funnel_pages']['sales']['page_setup']) && ($page_id = op_get_var($op['funnel_pages']['sales']['page_setup'], 'sales_page', 0)) > 0) { foreach ($options as $section => $fields) { $conf = op_get_var($op['funnel_pages']['sales'], $section); if ($section == 'page_setup') { $page_ids['sales'] = op_get_var($conf, 'sales_page', 0); if ($page_ids['sales'] > 0) { $used_ids[$page_ids['sales']] = true; $funnel_pages['sales']['sales_page'] = $page_ids['sales']; op_update_page_id_option($page_ids['sales'], array('launch_suite_info', array('funnel_id' => OP_LAUNCH_FUNNEL, 'funnel_page' => 'sales'))); } } $tmp = array(); foreach ($fields as $field) { $tmp[$field] = op_get_var($conf, $field); } $funnel_pages['sales'][$section] = $tmp; } } } if (empty($funnel_pages['sales'])) { $funnel_pages['sales'] = $op['funnel_pages']['sales']; } if (isset($op['funnel_pages']['stage'])) { $options = array('page_setup' => array('value_page'), 'page_thumbnails' => array('active_thumbnail', 'inactive_thumbnail'), 'navigation' => array('active_link_text', 'inactive_link_text'), 'publish_stage' => array('publish')); if ($this->is_key_on) { array_unshift($options['page_setup'], 'landing_page'); } if (isset($op['funnel_pages']['stage']) && is_array($op['funnel_pages']['stage'])) { $count = count(op_get_var($op['funnel_pages']['stage']['page_setup'], 'landing_page', array())); $configs = array('page_setup' => op_get_var($op['funnel_pages']['stage'], 'page_setup', array()), 'page_thumbnails' => op_get_var($op['funnel_pages']['stage'], 'page_thumbnails', array()), 'navigation' => op_get_var($op['funnel_pages']['stage'], 'navigation', array()), 'publish_stage' => op_get_var($op['funnel_pages']['stage'], 'publish_stage', array())); for ($i = 0; $i < $count; $i++) { $stage = array(); $pg_ids = array(); foreach ($options as $section => $fields) { $stage[$section] = array(); foreach ($fields as $field) { $stage[$section][$field] = op_get_var(op_get_var($configs[$section], $field, array()), $i); if ($field == 'active_link_text' && empty($stage[$section]['active_link_text'])) { $stage[$section]['active_link_text'] = get_the_title(op_get_var($stage, 'value_page')); } elseif ($field == 'inactive_link_text' && empty($stage[$section]['inactive_link_text'])) { $stage[$section]['inactive_link_text'] = 'Coming Soon'; } if ($field == 'landing_page' || $field == 'value_page') { $pg_ids[$field] = $stage[$section][$field]; $stage[$field] = $pg_ids[$field]; if ($pg_ids[$field] > 0) { $used_ids[$pg_ids[$field]] = true; op_update_page_id_option($pg_ids[$field], array('launch_suite_info', array('funnel_id' => OP_LAUNCH_FUNNEL, 'funnel_page' => 'stage', 'stage_idx' => $i, 'type' => $field))); } } } } $funnel_pages['stages'][] = $stage; $page_ids['stages'][] = $pg_ids; } } } } op_launch_update_option('funnel_pages', $funnel_pages); op_launch_update_option('page_ids', $page_ids); $funnel_pages = $wpdb->get_results($wpdb->prepare("SELECT page_id FROM `{$wpdb->prefix}optimizepress_launchfunnels_pages` WHERE funnel_id=%s", OP_LAUNCH_FUNNEL)); if ($funnel_pages) { $pages = array(); foreach ($funnel_pages as $page) { if (!isset($used_ids[$page->page_id])) { op_update_page_id_option($page->page_id, array('launch_suite_info', array('funnel_id' => OP_LAUNCH_FUNNEL, 'funnel_page' => 'stage', 'stage_idx' => -1, 'type' => ''))); } } } if (op_has_error()) { $this->error = __('There was a problem processing the form, please review the errors below', OP_SN); } else { $this->notification = __('Your launch suite settings have been updated.', OP_SN); } } else { $this->error = __('Verification failed, please refresh the page and try again.', OP_SN); } } }
/** * @see OptimizePress_Modules_Email_ProviderInterface::subscribe() */ public function subscribe($data) { if (isset($data['list']) && isset($data['email'])) { $mergeVars = $this->prepareMergeVars(); try { $contact = $this->getClient()->addContact($data['email'], 'normal', $mergeVars['prefix'], $mergeVars['name'], $mergeVars['last_name'], $mergeVars['sufix'], $mergeVars['street'], $mergeVars['street2'], $mergeVars['city'], $mergeVars['state'], $mergeVars['postal_code'], $mergeVars['phone'], $mergeVars['fax'], $mergeVars['business']); $this->logger->notice('Adding contact status: ' . print_r($contact, true)); $status = $this->getClient()->subscribeContactToList($contact->contactId, $data['list']); $this->logger->notice('Subscription status: ' . print_r($status, true)); /* * API returns empty status if user exists */ if (empty($status)) { if (isset($_POST['already_subscribed_url']) && op_post('already_subscribed_url') !== '') { $_POST['redirect_url'] = op_post('already_subscribed_url'); } else { if (isset($_POST['redirect_url'])) { $action = sprintf(__('<a href="javascript:history.go(-1);">Return to previous page</a> or <a href="%s">continue</a>.', 'optimizepress'), op_post('redirect_url')); } else { $action = __('<a href="javascript:history.go(-1);">Return to previous page.</a>', 'optimizepress'); } op_warning_screen(__('This email is already subscribed...', 'optimizepress'), __('Optin form - Warning', 'optimizepress'), $action); } } return true; } catch (Exception $e) { $this->logger->error('Error ' . $e->getCode() . ': ' . $e->getMessage()); return false; } } else { $this->logger->alert('Mandatory information not present [list and/or email address]'); wp_die('Mandatory information not present [list and/or email address].'); return false; } }
/** * Searches for possible form fields from POST and adds them to the collection * @param string $id * @return null|array Null if no value/field found */ protected function prepareMergeVars($id, $email) { $vars = array(); $allowed = array_keys($this->getFormFields($id)); foreach ($allowed as $name) { if ($name !== 'email' && false !== ($value = op_post($name))) { if (strrpos($name, "customfield_id_") !== false) { $customID = str_replace('customfield_id_', '', $name); $vars['field[' . $customID . ',0]'] = $value; } else { $vars[$name] = $value; } } } $vars['p[' . $id . ']'] = $id; $vars['email'] = $email; if (op_post('signup_form_id')) { $vars['form'] = op_post('signup_form_id'); } // Triggering instant responders $vars['instantresponders'] = 1; return $vars; }
function run_install() { //Get the global wordpress database object global $wpdb; //Make sure we are supposed to be running this function if (isset($_POST[OP_SN . '_install'])) { //Perform security verification if (isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'op_install')) { //Get the OP order number $key = op_post('op', 'install', 'order_number'); //Register the key and return key status $status = op_sl_register($key); //If the key is invalid, notify user, otherwise continue if (is_wp_error($status)) { //Save the API key op_sl_save_key($key); //Continue if the product is not already installed if (op_get_option('installed') != 'Y') { //CReate the Assets table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_assets` (\n\t\t\t\t\t\t\t `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t `name` varchar(64) NOT NULL DEFAULT '0',\n\t\t\t\t\t\t\t `title` varchar(150) NOT NULL DEFAULT '',\n\t\t\t\t\t\t\t `settings` varchar(1) NOT NULL DEFAULT 'N',\n\t\t\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the launch funnel table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_launchfunnels` (\n\t\t\t\t\t\t\t\t`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t`title` varchar(254) NOT NULL DEFAULT '',\n\t\t\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the launch funnel pages table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_launchfunnels_pages` (\n\t\t\t\t\t\t\t\t`funnel_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t\t\t\t\t`page_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t\t\t\t\t`step` int(10) unsigned NOT NULL\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the layout categories table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_layout_categories` (\n\t\t\t\t\t\t\t\t`id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t\t`name` varchar(255) NOT NULL,\n\t\t\t\t\t\t\t\tPRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the products table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_pb_products` (\n\t\t\t\t\t\t\t `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t `post_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t\t\t\t `parent_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t\t\t\t `type` varchar(50) NOT NULL DEFAULT '',\n\t\t\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the post layouts table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_post_layouts` (\n\t\t\t\t\t\t\t `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t `post_id` bigint(20) unsigned NOT NULL,\n\t\t\t\t\t\t\t `type` varchar(255) NOT NULL,\n\t\t\t\t\t\t\t `layout` longtext NOT NULL,\n\t\t\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the predefined layouts table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_predefined_layouts` (\n\t\t\t\t\t\t\t `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t `name` varchar(100) NOT NULL DEFAULT '',\n\t\t\t\t\t\t\t `category` int(10) unsigned NOT NULL,\n\t\t\t\t\t\t\t `description` text NOT NULL,\n\t\t\t\t\t\t\t `preview_ext` varchar(4) NOT NULL DEFAULT '',\n\t\t\t\t\t\t\t `layouts` longtext NOT NULL,\n\t\t\t\t\t\t\t `settings` longtext NOT NULL,\n\t\t\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Create the presets table $wpdb->query("CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}optimizepress_presets` (\n\t\t\t\t\t\t\t `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t\t\t\t\t `name` varchar(255) NOT NULL,\n\t\t\t\t\t\t\t `layouts` longtext NOT NULL,\n\t\t\t\t\t\t\t `settings` longtext NOT NULL,\n\t\t\t\t\t\t\t PRIMARY KEY (`id`)\n\t\t\t\t\t\t\t) ENGINE=MyISAM;"); //Save the assets _op_assets('save_assets'); //Set the installed flag to Y so the installer doesn't run again op_update_option('installed', 'Y'); //Ping pong if (!wp_next_scheduled('ping_pong')) { wp_schedule_event(time(), 'daily', 'ping_pong'); } //Set defaults $this->set_defaults(); // install content templates $this->install_content_templates(); //Redirect to the setup wizard if (defined('OP_TYPE') && OP_TYPE == 'theme') { wp_redirect(menu_page_url(OP_SN, false) . '-setup-wizard'); } else { wp_redirect(menu_page_url(OP_SN, false)); } } else { //Reload wp_redirect(menu_page_url(OP_SN, false)); } } } else { //If the security verification failed, notify the user $this->error = __('Verification failed, please refresh the page and try again.', OP_SN); } } }
/** * Searches for possible form fields from POST and adds them to the collection * @param AWeberEntry $list * @return null|array Null if no value/field found */ protected function prepareMergeVars($list) { $vars = array(); $allowed = array_keys($this->getFormFields($list)); foreach ($allowed as $name) { if (false !== ($value = op_post(str_replace(' ', '_', $name)))) { $vars[$name] = $value; } } if (count($vars) === 0) { $vars = null; } return $vars; }
/** * Searches for possible form fields from POST and adds them to the collection * @param string $id * @return null|array Null if no value/field found */ protected function prepareMergeVars($id) { $vars = array(); $allowed = array_keys($this->getFormFields($id)); foreach ($allowed as $name) { if ($name !== 'EMAIL' && false !== ($value = op_post($name))) { $vars[$name] = $value; } } if (count($vars) === 0) { $vars = null; } return $vars; }
/** * Prepare post vars and merge them with allowed form fields. * @return mixed */ protected function prepareMergeVars() { $vars = array(); $allowed = array_keys($this->getFormFields()); // $forbidden = array_merge($allowed, $this->forbiddenFields); foreach ($allowed as $name) { if (false !== ($value = op_post($name))) { $vars[$name] = $value; } } // foreach ($_POST as $name => $value) { // if (!in_array($name, $forbidden)) { // $vars[$name] = $value; // } // } if (count($vars) === 0) { $vars = null; } return $vars; }
/** * Searches for possible form fields from POST and adds them to the collection * @return null|array Null if no value/field found */ protected function prepareMergeVars() { $vars = array(); $fields = $this->getFields(); foreach ($fields as $key => $name) { if (false !== ($value = op_post($key))) { $vars[$name] = $value; } } if (count($vars) === 0) { $vars = null; } return $vars; }
/** * Searches for possible form fields from POST and adds them to the collection * @param string $id * @return null|array Null if no value/field found */ protected function prepareMergeVars($id) { $vars = array('validate_phone' => 0); $allowed = array_keys($this->getFormFields($id)); foreach ($allowed as $name) { if ($name !== 'email' && false !== ($value = op_post($name))) { $vars[$name] = $value; } } return $vars; }
/** * Searches for possible form fields from POST and adds them to the collection * @return null|array Null if no value/field found */ protected function prepareMergeVars() { $vars = array(); $allowed = array_keys($this->getExtraFields()); foreach ($allowed as $name) { $vars[$name] = op_post($name); } if (count($vars) === 0) { $vars = null; } return $vars; }
/** * Searches for possible form fields from POST and adds them to the collection * @param string $id * @return null|array Null if no value/field found */ protected function prepareMergeVars($id) { $vars = array(); $allowed = array_keys($this->getFormFields($id)); foreach ($allowed as $name) { if ('Name' !== $name && false !== ($value = op_post($name))) { $vars[] = array('Key' => $name, 'Value' => $value); } } return $vars; }
function save_meta_box($post_id) { if (!op_can_edit_page($post_id) || !isset($_POST['op_seo_meta_box']) || !wp_verify_nonce($_POST['op_seo_meta_box'], 'op_seo_meta_box')) { return; } if ($seo = op_post('op', 'seo')) { $newseo = array('title' => stripslashes(op_get_var($seo, 'title')), 'description' => stripslashes(op_get_var($seo, 'description')), 'keywords' => stripslashes(op_get_var($seo, 'keywords')), 'ogtitle' => stripslashes(op_get_var($seo, 'ogtitle')), 'ogdescription' => stripslashes(op_get_var($seo, 'ogdescription')), 'ogimage' => stripslashes(op_get_var($seo, 'ogimage'))); update_post_meta($post_id, '_' . OP_SN . '_seo', maybe_serialize($newseo)); } }
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 save_features() { //opLog('POST: ' . print_r($_POST, true)); //opLog('OPTIONS :' . print_r($this->options, true)); $font_options = op_page_option('feature_area', 'settings', 'font_options'); if (!is_array($font_options)) { $font_options = array(); } if ($this->enabled && count($this->options) > 0) { foreach ($this->options as $name => $options) { if ($name == 'template') { continue; } $op = op_post('feature_area', $name); $mod_options = op_get_var($options, 'mod_options', array()); $module = op_mod($options['module'], op_get_var($options, 'module_type', 'blog'))->save_settings(array('feature_area', $name), $mod_options, $op, true, true); if ($options['module'] == 'content_fields') { if (isset($module[0])) { $font_options[$name] = $module[1]; $module = $module[0]; } } op_update_page_option('feature_area', 'settings', $name, $module); } } op_update_page_option('feature_area', 'settings', 'font_options', $font_options); }
/** * Searches for possible form fields from POST and adds them to the collection * @param string $id * @return null|array Null if no value/field found */ protected function prepareMergeVars($id) { $vars = array(); $allowed = array_diff(array_keys($this->getFormFields($id)), array('first_name', 'last_name', 'phone', 'fax')); foreach ($allowed as $name) { if (false !== ($value = op_post($name))) { $vars[$name] = $value; } } $this->logger->notice('Merged vars: ' . print_r($vars, true)); if (count($vars) === 0) { $vars = null; } return $vars; }