function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $show_modified_date = $instance['show_modified_date']; $show_published_date = $instance['show_published_date']; $show_author = $instance['show_author']; global $post; $tzone = get_option('timezone_string'); date_default_timezone_set($tzone); $sdate = human_time_diff_plus(get_the_modified_time('U')); $pdate = human_time_diff_plus(date("U", strtotime($post->post_date))); $userid = $post->post_author; $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_about_this_page_children"; $aboutChildren = get_option($acf_key); if (is_single()) { $single = 'true'; } if (is_singular(array('forum', 'topic', 'reply'))) { $single_forum = 'true'; } $page = is_page(); $showabout = false; if ($single) { $showabout = true; } if ($single_forum) { $showabout = false; } if ($page) { $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array('post_type' => 'page', 'posts_per_page' => -1)); if ($aboutChildren) { foreach ((array) $aboutChildren as $a) { // Filter through all pages and find Portfolio's children $children = get_page_children($a, $all_wp_pages); if ($children) { foreach ($children as $c) { $child[] = $c->ID; if ($post->ID == $c->ID) { $showabout = true; } } } } } } $path = plugin_dir_url(__FILE__); wp_enqueue_script('ht_about_this_page_ajax', $path . 'ht_about_this_page_ajax.js'); $protocol = isset($_SERVER["HTTPS"]) ? 'https://' : 'http://'; $params = array('ajaxurl' => admin_url('admin-ajax.php', $protocol), 'title' => $title, 'before_widget' => stripcslashes($before_widget), 'after_widget' => stripcslashes($after_widget), 'before_title' => stripcslashes($before_title), 'after_title' => stripcslashes($after_title), 'show_modified_date' => $show_modified_date, 'show_published_date' => $show_published_date, 'show_author' => $show_author, 'single' => $single, 'single_forum' => $single_forum, 'page' => $page, 'sdate' => $sdate, 'pdate' => $pdate, 'userid' => $userid, 'showabout' => $showabout); wp_localize_script('ht_about_this_page_ajax', 'ht_about_this_page_ajax', $params); echo "<div id='ht_about_this_page_ajax' class='ht_about_this_page_ajax'></div>"; }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $show_modified_date = $instance['show_modified_date']; $show_published_date = $instance['show_published_date']; $show_author = $instance['show_author']; $showabout = false; if (is_single()) { $showabout = true; } if (is_singular(array('forum', 'topic', 'reply'))) { $showabout = false; } if (is_page()) { $acf_key = "widget_" . $this->id_base . "-" . $this->number . "_about_this_page_children"; $aboutChildren = get_option($acf_key); global $post; $my_wp_query = new WP_Query(); $all_wp_pages = $my_wp_query->query(array('post_type' => 'page', 'posts_per_page' => -1)); if ($aboutChildren) { foreach ($aboutChildren as $a) { // Filter through all pages and find Portfolio's children $children = get_page_children($a, $all_wp_pages); if ($children) { foreach ($children as $c) { $child[] = $c->ID; if ($post->ID == $c->ID) { $showabout = true; } } } } } } if ($showabout) { echo $before_widget; echo "<div id='about-this-widget'>"; if ($title) { echo $before_title . $title . $after_title; } $tzone = get_option('timezone_string'); date_default_timezone_set($tzone); if ($show_modified_date == 'on') { $sdate = human_time_diff_plus(get_the_modified_time('U')); if ($sdate == "0 mins") { $sdate = " " . __("just now", "govintranet"); } else { $sdate = sprintf(__('%s ago', 'govintranet'), $sdate); } echo __('Updated', 'govintranet') . " <time datetime='" . $sdate . "'>" . $sdate . "</time><br>"; } if ($show_published_date == 'on') { $sdate = date(get_option('date_format'), strtotime(get_the_date())); $sdate = human_time_diff_plus(get_the_time('U')); if ($sdate == "0 mins") { $sdate = " " . __("just now", "govintranet"); } else { $sdate = sprintf(__('%s ago', 'govintranet'), $sdate); } echo __('Published', 'govintranet') . " <time datetime='" . $sdate . "'>" . $sdate . "</time><br>"; } if ($show_author == 'on') { $useremail = get_the_author_meta('user_email'); echo "<a href='mailto:" . $useremail . "'>"; the_author(); echo "</a>"; } echo "</div>"; echo $after_widget; } }
function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); $show_modified_date = $instance['show_modified_date']; $show_published_date = $instance['show_published_date']; $show_author = $instance['show_author']; $showabout = false; if (is_single() || is_page()) { $showabout = true; } if (is_page() && pods_url_variable(0) == 'about') { $showabout = false; } if (pods_url_variable(0) == 'about' && pods_url_variable(1)) { $showabout = false; } if (pods_url_variable(0) == 'about' && pods_url_variable(2)) { $showabout = true; } if (pods_url_variable(0) == 'forum') { $showabout = false; } if (pods_url_variable(0) == 'topic') { $showabout = false; } if (pods_url_variable(0) == 'reply') { $showabout = false; } if (pods_url_variable(0) == 'task-by-category') { $showabout = false; } if (pods_url_variable(0) == 'news-by-category') { $showabout = false; } if (pods_url_variable(0) == 'newspage') { $showabout = false; } if (pods_url_variable(0) == 'how-do-i') { $showabout = false; } if (pods_url_variable(0) == 'tasks') { $showabout = false; } if (pods_url_variable(0) == 'events') { $showabout = false; } if (pods_url_variable(0) == 'tagged') { $showabout = false; } if ($showabout) { echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } $tzone = get_option('timezone_string'); date_default_timezone_set($tzone); if ($show_modified_date == 'on') { $sdate = human_time_diff_plus(get_the_modified_time('U')); if ($sdate == "0 mins") { $sdate = " just now"; } else { $sdate = $sdate . " ago"; } echo "Updated <time datetime='" . $sdate . "'>" . $sdate . "</time><br>"; } if ($show_published_date == 'on') { $sdate = date("j M Y", strtotime(get_the_date())); $sdate = human_time_diff_plus(get_the_time('U')); if ($sdate == "0 mins") { $sdate = " just now"; } else { $sdate = $sdate . " ago"; } echo "Published <time datetime='" . $sdate . "'>" . $sdate . "</time><br>"; } if ($show_author == 'on') { $useremail = get_the_author_meta('user_email'); echo "<a href='mailto:" . $useremail . "'>"; the_author(); echo "</a>"; } echo $after_widget; } }