Example #1
0
/**
 * Render preheader html where needed
 * @since 0.1.0
 */
function ls_render_pre_header()
{
    $ls_helpers = new ls_helpers();
    // Check if user has connected his account to vcita
    $is_vcita_connected = ls_is_vcita_connected();
    $settings = ls_get_settings();
    // Only when vcita account is connected
    if ($is_vcita_connected) {
        // Shortcut to stored vcita params
        $vcita_settings = $settings['vcita_params'];
        $vcita_email = $vcita_settings['email'];
    }
    ?>
<div class="ls-pre-header">
    <?php 
    if ($is_vcita_connected) {
        ?>
        <span>Logged in as: </span>
        <a class="ls-pre-header__email" href="mailto: <?php 
        echo $vcita_email;
        ?>
"> <?php 
        echo $vcita_email;
        ?>
</a>
        <span> | </span>
    <?php 
    }
    ?>
    <span><?php 
    _e('Rate us', 'livesite');
    ?>
: </span>
    <a class="ls-pre-header__rate-link"
       href="https://wordpress.org/support/view/plugin-reviews/contact-form-with-a-meeting-scheduler-by-vcita?filter=5"
       target="_blank">
        <span class="icon-Rate"></span><!--
        --><span class="icon-Rate"></span><!--
        --><span class="icon-Rate"></span><!--
        --><span class="icon-Rate"></span><!--
        --><span class="icon-Rate"></span></a>
    <a href="https://www.vcita.com/home?<?php 
    echo $ls_helpers->get_plugin_identifier();
    ?>
" target="_blank" class="ls-pre-header__logo"></a>
</div>
<?php 
}
Example #2
0
 /**
  * Add livesite scheduler shortcode
  * @since 0.1.0
  */
 function livesite_scheduler_shortcode($atts)
 {
     // Attributes
     $atts = shortcode_atts(array('title' => 'Contact request', 'class' => ''), $atts, 'livesite');
     // Set contact form title
     $title = 'title=' . wp_strip_all_tags($atts['title']);
     // Check if user has a custom class
     if ($atts['class'] != '') {
         $class = 'class="' . wp_strip_all_tags($atts['class']) . '"';
     } else {
         $class = '';
     }
     // Get UID
     $settings = ls_get_settings();
     $uid = $settings['vcita_params']['uid'];
     // Generate html
     $html = '<iframe frameborder="0" ' . $class . ' src="//www.vcita.com/widgets/scheduler/' . urlencode($uid) . '?ver=2" width="100%" height="470"></iframe>';
     return $html;
 }
Example #3
0
 /**
  * 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'));
     }
 }
Example #4
0
/**
 * Settings
 * Used to check if the plugin was upgraded so modules know not to auto intall pages`
 * @return: Boolean
 * @since 2.3.0
 */
function ls_is_plugin_upgraded()
{
    $settings = ls_get_settings();
    return isset($settings['plugin_upgraded']) ? $settings['plugin_upgraded'] : false;
}
Example #5
0
 /**
  * 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 );
 }