public function widget($args, $instance) { $this->instance = $instance; $title_text = isset($instance['title']) ? $instance['title'] : ''; $first_char = hocwp_get_first_char($title_text); if ('!' === $first_char) { $title_text = ltrim($title_text, '!'); } $banner_image = isset($instance['banner_image']) ? $instance['banner_image'] : ''; $banner_url = isset($instance['banner_url']) ? $instance['banner_url'] : ''; $banner_image = hocwp_sanitize_media_value($banner_image); $banner_image = $banner_image['url']; if (!empty($banner_image)) { hocwp_widget_before($args, $instance); $img = new HOCWP_HTML('img'); $img->set_image_src($banner_image); $img->set_image_alt($title_text); $img->set_class('hocwp-banner-image'); $html = $img->build(); if (!empty($banner_url)) { $a = new HOCWP_HTML('a'); $a->set_class('hocwp-banner-link'); $a->set_attribute('title', $title_text); $a->set_href($banner_url); $a->set_text($html); $nofollow = hocwp_get_value_by_key($instance, 'nofollow', hocwp_get_value_by_key($this->args, 'nofollow')); if ((bool) $nofollow) { $a->set_attribute('rel', 'nofollow'); } $html = $a->build(); } $widget_html = apply_filters('hocwp_widget_banner_html', $html, $args, $instance, $this); echo $widget_html; hocwp_widget_after($args, $instance); } }
function hocwp_loading_image($args = array()) { $name = hocwp_get_value_by_key($args, 'name', 'icon-loading-circle-16.gif'); $class = hocwp_get_value_by_key($args, 'class'); hocwp_add_string_with_space_before($class, 'img-loading'); $alt = hocwp_get_value_by_key($args, 'alt'); $display = hocwp_get_value_by_key($args, 'display', 'none'); $style = 'display: ' . $display; $img = new HOCWP_HTML('img'); $image_url = hocwp_get_image_url($name); $img->set_image_alt($alt); $img->set_class($class); $img->set_attribute('style', $style); $img->set_image_src($image_url); $img->output(); }
function hocwp_setup_theme_more_user_profile($user) { $user_id = $user->ID; ?> <h3><?php _e('Social Accounts', 'hocwp-theme'); ?> </h3> <table class="form-table"> <tr> <th><label for="facebook">Facebook</label></th> <td> <?php $facebook = get_the_author_meta('facebook', $user_id); $input = new HOCWP_HTML('input'); $input->set_attribute('name', 'facebook'); if (empty($facebook)) { $input->set_attribute('type', 'button'); $input->set_text(__('Connect with Facebook account', 'hocwp-theme')); $input->set_class('button button-secondary hide-if-no-js hocwp-connect-facebook facebook'); $input->set_attribute('onclick', 'hocwp_facebook_login();'); } else { $facebook_data = get_the_author_meta('facebook_data', $user_id); $avatar = hocwp_get_value_by_key($facebook_data, array('picture', 'data', 'url')); $email = hocwp_get_value_by_key($facebook_data, 'email'); if (!empty($avatar)) { $img = new HOCWP_HTML('img'); $img->set_image_alt(''); $img->set_image_src($avatar); } $input->set_attribute('type', 'text'); $input->set_attribute('readonly', 'readonly'); $input->set_attribute('value', $facebook . ' - ' . $email); $input->set_class('regular-text hocwp-disconnect-social facebook'); $input->set_attribute('data-user-id', $user_id); $input->set_attribute('data-social', 'facebook'); } if (empty($facebook) && 'profile.php' == $GLOBALS['pagenow']) { $input->output(); if (empty($facebook)) { hocwp_facebook_login_script(array('connect' => true)); } } else { if (!empty($facebook)) { $input->output(); } else { _e('You can only connect to social account on profile page.', 'hocwp-theme'); } } ?> </td> </tr> <tr> <th><label for="google">Google</label></th> <td> <?php $social = 'google'; $social_id = get_the_author_meta($social, $user_id); $input = new HOCWP_HTML('input'); $input->set_attribute('name', $social); if (empty($social_id)) { $input->set_attribute('type', 'button'); $input->set_text(__('Connect with Google account', 'hocwp-theme')); $input->set_class('button button-secondary hide-if-no-js hocwp-connect-' . $social . ' ' . $social); $input->set_attribute('onclick', 'hocwp_google_login();'); } else { $facebook_data = get_the_author_meta($social . '_data', $user_id); $avatar = hocwp_get_value_by_key($facebook_data, array('picture', 'data', 'url')); $email = hocwp_get_value_by_key($facebook_data, array('emails', 0, 'value')); if (!empty($avatar)) { $img = new HOCWP_HTML('img'); $img->set_image_alt(''); $img->set_image_src($avatar); } $input->set_attribute('type', 'text'); $input->set_attribute('readonly', 'readonly'); $input->set_attribute('value', $social_id . ' - ' . $email); $input->set_class('regular-text hocwp-disconnect-social ' . $social); $input->set_attribute('data-user-id', $user_id); $input->set_attribute('data-social', $social); } if (empty($social_id) && 'profile.php' == $GLOBALS['pagenow']) { $input->output(); if (empty($social_id)) { hocwp_google_login_script(array('connect' => true)); } } else { if (!empty($social_id)) { $input->output(); } else { _e('You can only connect to social account on profile page.', 'hocwp-theme'); } } ?> </td> </tr> </table> <?php }
function hocwp_lostpassword_form($args = array()) { $defaults = hocwp_account_form_default_args(); $args = wp_parse_args($args, $defaults); $data = hocwp_execute_lostpassword(); $user_login = $data['user_login']; $error = $data['error']; $message = $data['message']; $redirect_to = hocwp_get_value_by_key($args, 'redirect_to', hocwp_get_method_value('redirect_to', 'get')); $logo = hocwp_get_value_by_key($args, 'logo', hocwp_get_login_logo_url()); ?> <div class="hocwp-login-box module"> <div class="module-header text-center"> <?php if (!empty($logo)) { $a = new HOCWP_HTML('a'); $a->set_href(home_url('/')); $a->set_class('logo'); $img = new HOCWP_HTML('img'); $img->set_image_alt(''); $img->set_image_src($logo); $a->set_text($img->build()); $a->output(); } $slogan = new HOCWP_HTML('p'); $slogan->set_class('slogan'); $slogan->set_text(sprintf($args['slogan'], hocwp_get_root_domain_name(home_url('/')))); $slogan->output(); if (isset($_POST['submit']) || isset($_POST['wp-submit'])) { if (isset($_REQUEST['error']) || $error) { $message = hocwp_build_message($message, 'danger'); echo $message; } else { if (!empty($message) && !$error || isset($_POST['submit']) && !empty($message)) { $message = hocwp_build_message($message, 'success'); echo $message; } } } ?> </div> <div class="module-body"> <h4 class="form-title"><?php _e('Reset password', 'hocwp-theme'); ?> </h4> <form name="lostpasswordform" id="lostpasswordform" action="<?php echo esc_url(wp_lostpassword_url()); ?> " method="post"> <p> <label><?php echo hocwp_get_value_by_key($args, 'label_username', __('Username or Email', 'hocwp-theme')); ?> <br> <input type="text" size="20" value="<?php echo esc_attr($user_login); ?> " class="input" id="user_login" name="user_login"></label> </p> <input type="hidden" name="action" value="lostpassword"> <input type="hidden" name="redirect_to" value="<?php echo $redirect_to; ?> "> <p class="submit"> <input type="submit" name="wp-submit" id="wp-submit" class="button-primary" value="Get New Password" tabindex="100"></p> </form> </div> <div class="module-footer"> <div class="text-center"> <p class="form-nav"> <a href="<?php echo esc_url(wp_login_url()); ?> "><?php echo hocwp_get_value_by_key($args, 'label_log_in', __('Login', 'hocwp-theme')); ?> </a> <span class="sep">|</span> <a href="<?php echo esc_url(wp_lostpassword_url()); ?> " title="<?php echo $args['title_lostpassword_link']; ?> "><?php echo $args['text_lostpassword_link']; ?> </a> </p> </div> </div> </div> <?php }