function hocwp_debug_log_ajax_callback() { $object = hocwp_get_method_value('object'); $object = hocwp_json_string_to_array($object); hocwp_debug_log($object); exit; }
public function widget($args, $instance) { $this->instance = $instance; $page_name = isset($instance['page_name']) ? $instance['page_name'] : ''; $href = isset($instance['href']) ? $instance['href'] : ''; $width = isset($instance['width']) ? $instance['width'] : $this->args['width']; $height = isset($instance['height']) ? $instance['height'] : $this->args['height']; $hide_cover = (bool) (isset($instance['hide_cover']) ? $instance['hide_cover'] : $this->args['hide_cover']); $show_facepile = (bool) (isset($instance['show_facepile']) ? $instance['show_facepile'] : $this->args['show_facepile']); $hide_cta = (bool) (isset($instance['hide_cta']) ? $instance['hide_cta'] : $this->args['hide_cta']); $small_header = (bool) (isset($instance['small_header']) ? $instance['small_header'] : $this->args['small_header']); $adapt_container_width = (bool) (isset($instance['adapt_container_width']) ? $instance['adapt_container_width'] : $this->args['adapt_container_width']); $fixed = hocwp_get_value_by_key($instance, 'fixed', $this->args['fixed']); $only_link = hocwp_get_value_by_key($instance, 'only_link', $this->args['only_link']); $button_text = hocwp_get_value_by_key($instance, 'button_text', $this->args['button_text']); $before_widget = hocwp_get_value_by_key($args, 'before_widget'); $widget_class = ''; if ($fixed) { hocwp_add_string_with_space_before($widget_class, 'fixed'); $position = hocwp_get_value_by_key($instance, 'position', $this->args['position']); hocwp_add_string_with_space_before($widget_class, hocwp_sanitize_html_class($position)); } $before_widget = hocwp_add_class_to_string('', $before_widget, $widget_class); $args['before_widget'] = $before_widget; $img = new HOCWP_HTML('img'); $img->set_image_src(hocwp_get_image_url('icon-facebook-messenger-white-64.png')); $img->set_class('icon-messenger'); hocwp_widget_before($args, $instance); if ($only_link) { if (!hocwp_is_url($href)) { $href = 'https://m.me/' . $href; } $span = new HOCWP_HTML('span'); $span->set_text($button_text); $link_text = $img->build(); $link_text .= $span->build(); $a = new HOCWP_HTML('a'); $a->add_class('button btn btn-facebook-messenger'); $a->set_text($link_text); $a->set_href($href); $widget_html = $a->build(); } else { $app_id = hocwp_get_wpseo_social_facebook_app_id(); if (empty($app_id)) { hocwp_debug_log(__('Please set your Facebook APP ID first.', 'hocwp-theme')); return; } add_filter('hocwp_use_facebook_javascript_sdk', '__return_true'); ?> <script type="text/javascript"> window.fbAsyncInit = function () { FB.init({ appId: '<?php echo $app_id; ?> ', cookie: true, xfbml: true, version: 'v<?php echo HOCWP_FACEBOOK_JAVASCRIPT_SDK_VERSION; ?> ' }); }; </script> <?php $fanpage_args = array('page_name' => $page_name, 'href' => $href, 'width' => $width, 'height' => $height, 'tabs' => 'messages', 'hide_cover' => $hide_cover, 'show_facepile' => $show_facepile, 'hide_cta' => $hide_cta, 'small_header' => $small_header, 'adapt_container_width' => $adapt_container_width); ob_start(); if ($fixed) { $fanpage_args['width'] = 300; ?> <div class="messenger-box module"> <div class="module-header heading btn-facebook-messenger" title="<?php echo $button_text; ?> "> <?php $img->output(); ?> <label><?php echo $button_text; ?> </label> <?php if ('left' == $position || 'right' == $position) { echo '<i class="fa fa-times" aria-hidden="true"></i>'; $span = new HOCWP_HTML('span'); $span->add_class('facebook-messenger-box-control'); $span->set_text($img); $span->output(); } else { echo '<i class="fa fa-angle-up" aria-hidden="true"></i>'; } ?> </div> <div class="module-body"> <?php hocwp_facebook_page_plugin($fanpage_args); ?> </div> </div> <?php } else { hocwp_facebook_page_plugin($fanpage_args); } $widget_html = ob_get_clean(); } $widget_html = apply_filters('hocwp_widget_facebook_messenger_html', $widget_html, $args, $instance, $this); echo $widget_html; hocwp_widget_after($args, $instance); }
function hocwp_generate_min_file($file, $extension = 'js', $compress_min_file = false, $force_compress = false) { $transient_name = 'hocwp_minified_%s'; $transient_name = hocwp_build_transient_name($transient_name, $file); if (false === get_transient($transient_name) || $force_compress) { if (file_exists($file)) { $extension = strtolower($extension); if ('js' === $extension) { $minified = hocwp_minify_js($file); } else { $minified = hocwp_minify_css($file, true); } if (!empty($minified)) { if ($compress_min_file) { if (!file_exists($file)) { $handler = fopen($file, 'w'); fwrite($handler, $minified); fclose($handler); } else { @file_put_contents($file, $minified); } } else { $info = pathinfo($file); $basename = $info['basename']; $filename = $info['filename']; $extension = $info['extension']; $min_name = $filename; $min_name .= '.min'; if (!empty($extension)) { $min_name .= '.' . $extension; } $min_file = str_replace($basename, $min_name, $file); $handler = fopen($min_file, 'w'); fwrite($handler, $minified); fclose($handler); } set_transient($transient_name, 1, 15 * MINUTE_IN_SECONDS); hocwp_debug_log(sprintf(__('File %s is compressed successfully!', 'hocwp-theme'), $file)); } } } }