/** * Create Settings Page * @since 0.1.0 */ function ls_settings_setup() { $ls_helpers = $this->ls_helpers; // Setup small link on wordpress plugins page that directs user to settings page add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2); /* Add settings menu page */ $settings_page = add_menu_page('LiveSite Pack', 'LiveSite', 'manage_options', 'live-site', array($this, 'ls_settings_page'), plugin_dir_url(__FILE__) . 'images/vcita-icon.png', '2.3489'); $os = $ls_helpers->get_os(); // For popular os (unix) if ($os != 'win32') { define('LS_SLASH', '/'); } else { define('LS_SLASH', '\\'); } // If settings don't exist in db set them up from defaults if (!ls_get_settings()) { ls_init_default_settings(); } // Check if vcita is not connected // If old connection details are in place use them if (!ls_is_vcita_connected()) { $old_plugin_db_key = $ls_helpers->get_old_plugin_db_key(); // Get old plugin connection details $old_connection_options = get_option($old_plugin_db_key); // Setup connection details if ($old_connection_options) { ls_parse_old_plugin_params($old_connection_options); // Flag plugin as upgraded plugin so we know not to auto install module pages ls_set_settings(array('plugin_upgraded' => true)); $vcita_params = ls_get_vcita_params(); // Set value of active engage widget to the same value as the old plugin if (isset($vcita_params['engage_active'])) { ls_set_module_data('livesite_widget', array('show_livesite' => $vcita_params['engage_active'])); } $redirect_url = $ls_helpers->get_plugin_path(); wp_redirect($redirect_url); exit; } } // Only show modules and settings if we're connected to vcita if (ls_is_vcita_connected()) { require_once 'system/settings_page.php'; require_once 'system/backoffice_page.php'; $this->init_modules(); $main_module = ls_get_main_module(); $settings = ls_get_settings(); // For a one time redirect after vcita connect if (!$settings['plugin_initially_activated']) { // Set plugin as already activated, this only allows it to happen once when we connect to vcita ls_set_settings(array('plugin_initially_activated' => true)); // Get main module data $module_data = ls_get_module_data($main_module); // Redirect to main module page $plugin_page_url = $ls_helpers->get_plugin_page_url($module_data['slug']); wp_redirect($plugin_page_url); exit; } } /* Vars */ $page_hook_id = $this->setings_page_id(); /* Do stuff in settings page, such as adding scripts, etc. */ if (!empty($settings_page)) { /* Load the JavaScript needed for the settings screen. */ add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); add_action('admin_enqueue_scripts', array($this, 'enqueue_styles')); } }
/** * Settings * Replaces double curly braces with vcita data in modules * @param: $vcita_data{Array} * @since 0.1.0 */ function ls_replace_default_tags() { $modules = ls_get_modules(); $settings = ls_get_settings(); // $ls_helpers->console_log( $settings ); // Run over all modules foreach ($modules as $module_name => $module) { if (isset($module['custom_page_content'])) { // Replace data inside of custom page content $custom_page_content_parsed = $this->tag_replace($module['custom_page_content'], $settings['vcita_params']); // TODO: Fix this. For some reason ls_set_settings overrides the vcita_params and does not merge the arrays correctly // Set module as active based on array key name ls_set_module_data($module_name, array('custom_page_content' => $custom_page_content_parsed)); // $ls_helpers->console_log( $ ); } } // $ls_helpers->console_log( $modules ); }