Exemplo n.º 1
0
 public static function widget($instance = array())
 {
     //Extract widget arguments
     //Merge instance options with global default options
     $lwa_data = wp_parse_args($instance, self::$data);
     //Deal with specific variables
     $is_widget = false;
     //backwards-comatibility for overriden themes, this is now done within the WP_Widget class
     $lwa_data['profile_link'] = !empty($lwa_data['profile_link']) && $lwa_data['profile_link'] != "false";
     //Add template logic
     self::$template = !empty($lwa_data['template']) && array_key_exists($lwa_data['template'], self::$templates) ? $lwa_data['template'] : 'default';
     //Choose the widget content to display.
     if (is_user_logged_in()) {
         //Firstly check for template in theme with no template folder (legacy)
         $template_loc = locate_template(array('plugins/login-with-ajax/widget_in.php'));
         //Then check for custom templates or theme template default
         $template_loc = $template_loc == '' && self::$template ? self::$templates[self::$template] . '/widget_in.php' : $template_loc;
         include $template_loc != '' && file_exists($template_loc) ? $template_loc : 'widget/default/widget_in.php';
     } else {
         //Firstly check for template in theme with no template folder (legacy)
         $template_loc = locate_template(array('plugins/login-with-ajax/widget_out.php'));
         //First check for custom templates or theme template default
         $template_loc = $template_loc == '' && self::$template ? self::$templates[self::$template] . '/widget_out.php' : $template_loc;
         include $template_loc != '' && file_exists($template_loc) ? $template_loc : 'widget/default/widget_out.php';
     }
 }
Exemplo n.º 2
0
 public static function widget($instance = array())
 {
     //Extract widget arguments
     //Merge instance options with global default options
     $lwa_data = wp_parse_args($instance, self::$data);
     //Deal with specific variables
     $is_widget = false;
     //backwards-comatibility for overriden themes, this is now done within the WP_Widget class
     $lwa_data['profile_link'] = !empty($lwa_data['profile_link']) && $lwa_data['profile_link'] != "false";
     //Add template logic
     self::$template = !empty($lwa_data['template']) && array_key_exists($lwa_data['template'], self::$templates) ? $lwa_data['template'] : 'default';
     //Choose the widget content to display.
     if (is_user_logged_in()) {
         //Firstly check for template in theme with no template folder (legacy)
         $template_loc = locate_template(array('plugins/login-with-ajax/widget_in.php'));
         //Then check for custom templates or theme template default
         $template_loc = $template_loc == '' && self::$template ? self::$templates[self::$template] . '/widget_in.php' : $template_loc;
         include $template_loc != '' && file_exists($template_loc) ? $template_loc : 'widget/default/widget_in.php';
     } else {
         //quick/easy WPML fix, should eventually go into a seperate file
         if (defined('ICL_LANGUAGE_CODE')) {
             if (!function_exists('lwa_wpml_input_var')) {
                 function lwa_wpml_input_var()
                 {
                     echo '<input type="hidden" name="lang" id="lang" value="' . esc_attr(ICL_LANGUAGE_CODE) . '" />';
                 }
             }
             foreach (array('login_form', 'lwa_register_form', 'lostpassword_form') as $action) {
                 add_action($action, 'lwa_wpml_input_var');
             }
         }
         //Firstly check for template in theme with no template folder (legacy)
         $template_loc = locate_template(array('plugins/login-with-ajax/widget_out.php'));
         //First check for custom templates or theme template default
         $template_loc = $template_loc == '' && self::$template ? self::$templates[self::$template] . '/widget_out.php' : $template_loc;
         include $template_loc != '' && file_exists($template_loc) ? $template_loc : 'widget/default/widget_out.php';
         //quick/easy WPML fix, should eventually go into a seperate file
         if (defined('ICL_LANGUAGE_CODE')) {
             foreach (array('login_form', 'lwa_register_form', 'lostpassword_form') as $action) {
                 remove_action($action, 'lwa_wpml_input_var');
             }
         }
     }
 }