Example #1
2
function base_getBreadcrumbs()
{
    if (is_404()) {
        return false;
    }
    // Hack to fix breadcrumbs when you're viewing the news home
    if (is_home()) {
        $post = new \Timber\Post(get_option('page_for_posts'));
    } else {
        global $post;
    }
    $breadcrumbs = [];
    if ($post->post_parent) {
        $parent_id = $post->post_parent;
        while ($parent_id) {
            $page = get_page($parent_id);
            $breadcrumbs[] = new \Timber\Post($page->ID);
            $parent_id = $page->post_parent;
        }
        $breadcrumbs = array_reverse($breadcrumbs);
    }
    // Add 'Blog Home' to breadcrumbs if you're on a news post or archive
    if ((is_single() || is_archive()) && !is_search()) {
        $breadcrumbs[] = new \Timber\Post(get_option('page_for_posts'));
    }
    return $breadcrumbs;
}
Example #2
0
function show_content($page_id, $is_mobile = false)
{
    $page_data = get_page($page_id);
    $content = $page_data->post_content;
    $content = apply_filters('the_content', $content);
    echo $content;
}
Example #3
0
function rss_check_feed_content($url, $feed_config)
{
    global $config;
    if (strpos($url, '?') === false) {
        $url .= '?kvs_test_feed=true';
    } else {
        $url .= '&kvs_test_feed=true';
    }
    $feed_contents = get_page('', $url, '', '', 1, 0, 600, '');
    if (strlen($feed_contents) == 0) {
        return null;
    }
    if ($feed_config['feed_charset'] != '' && function_exists('iconv')) {
        $feed_contents = iconv($feed_config['feed_charset'], "utf8", $feed_contents);
    }
    preg_match_all("|<item>(.*?)</item>|is", $feed_contents, $temp);
    $items = $temp[1];
    $result = array();
    foreach ($items as $item) {
        $video_record = rss_parse_item($item);
        $video_record['external_key'] = $video_record['website_link'];
        return $video_record;
    }
    return null;
}
function merge_comment_count($count, $post_ID)
{
    // get all the languages for which this post exists
    $languages = icl_get_languages('skip_missing=1');
    $post = get_post($post_ID);
    $type = $post->post_type;
    foreach ($languages as $l) {
        // in $count is already the count from the current language
        if (!$l['active']) {
            $otherID = icl_object_id($post_ID, $type, false, $l['language_code']);
            if ($otherID) {
                // cannot use call_user_func due to php regressions
                if ($type == 'page') {
                    $otherpost = get_page($otherID);
                } else {
                    $otherpost = get_post($otherID);
                }
                if ($otherpost) {
                    // increment comment count using translation post comment count.
                    $count = $count + $otherpost->comment_count;
                }
            }
        }
    }
    return $count;
}
 /**
  * create optional test nav menu
  * 
  * At least two custom menus should be created in order to test a theme
  * The standard Theme data file now ships with optimal menus built-in
  * This method actually makes sense with custom WXR files only
  * 
  * @since 0.2
  */
 private function create_test_menus()
 {
     $pages = get_all_page_ids();
     $items = array();
     foreach ($pages as $page_ID) {
         $info = get_page($page_ID);
         $items[$info->post_title] = get_permalink($page_ID);
     }
     # pick three random entries
     $random = array_rand($items, 3);
     # build menus
     $menus = array('Full Menu' => array('slug' => 'full-menu', 'menu_items' => $items), 'Short Menu' => array('slug' => 'short-menu', 'menu_items' => array($items[$random[0]], $items[$random[1]], $items[$random[2]])));
     # register menus
     foreach ($menus as $title => $data) {
         register_nav_menu($data['slug'], $title);
         if (false == is_nav_menu($title)) {
             $menu_ID = wp_create_nav_menu($title);
             foreach ($data['menu_items'] as $name => $url) {
                 $add_item = array('menu-item-type' => 'custom', 'menu-item-url' => $url, 'menu-item-title' => $name);
                 wp_update_nav_menu_item($menu_ID, 0, $add_item);
             }
             WP_CLI::success('Created menu ' . $title);
         }
     }
 }
Example #6
0
 function start_el(&$output, $page, $depth, $args, $current_page)
 {
     if ($depth) {
         $indent = str_repeat("\t", $depth);
     } else {
         $indent = '';
     }
     extract($args, EXTR_SKIP);
     $css_class = array('page_item', 'page-item-' . $page->ID);
     if (!empty($current_page)) {
         $_current_page = get_page($current_page);
         _get_post_ancestors($_current_page);
         if (isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors)) {
             $css_class[] = 'current_page_ancestor';
         }
         if ($page->ID == $current_page) {
             $css_class[] = 'current_page_item bodyguard';
             // added bodyguard class to prevent current_page_item class from being removed
             //Span injection sent to $output if active page
             $active_arrow = '<span class="active"></span>';
         } elseif ($_current_page && $page->ID == $_current_page->post_parent) {
             $css_class[] = 'current_page_parent';
         }
     } elseif ($page->ID == get_option('page_for_posts')) {
         $css_class[] = 'current_page_parent';
     }
     $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page));
     $output .= $indent . '<li class="' . $css_class . '">' . $active_arrow . '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(wp_strip_all_tags(apply_filters('the_title', $page->post_title, $page->ID))) . '">' . $link_before . apply_filters('the_title', $page->post_title, $page->ID) . $link_after . '</a>';
 }
function myAjaxFunc()
{
    /*
     *   vars
     */
    $page_id = json_decode($_POST['postID']);
    $page_object = get_page($page_id);
    $content = $page_object->post_content;
    $content = apply_filters('the_content', $content);
    /*
     *   remove characters to get correct number of words count
     */
    // remove &nbsp; from content string
    $content = preg_replace("/&#?[a-z0-9]{2,8};/i", "", $content);
    // remove whitespaces after html tags from content string
    $content = str_replace('> ', '', $content);
    // return post content in json format
    if (!empty($page_object)) {
        header("Content-type: application/json");
        echo json_encode(array('content' => $content));
        return true;
    } else {
        return false;
    }
}
 function add_custom_to_yoast($content)
 {
     global $post;
     $pid = $post->ID;
     $pg = get_page($pid);
     $custom_content = '';
     if ($post->post_name == 'feedback') {
         $feedback_args = array('posts_per_page' => 4, 'post_type' => 'mp_feedback_cpt');
         $feedback = get_posts($feedback_args);
         $custom_content .= "<h2>Client " . get_the_title($post->ID) . "</h2>";
         if (!empty($feedback)) {
             foreach ($feedback as $fb) {
                 $custom_content .= '<div class="well text-center">';
                 $custom_content .= $fb->post_content;
                 $custom_content .= '</div>';
             }
         }
     }
     if ($post->post_name == 'case-studies') {
         $case_study_args = array('posts_per_page' => 4, 'post_type' => 'mp_case_study_cpt');
         $case_studies = get_posts($case_study_args);
         $custom_content .= "<h2>Case Summaries</h2>";
         if (!empty($case_studies)) {
             foreach ($case_studies as $cs) {
                 $custom_content .= '<div class="well">';
                 $custom_content .= $cs->post_content;
                 $custom_content .= '</div>';
             }
         }
     }
     return $content . ' ' . $custom_content;
     remove_filter('wpseo_pre_analysis_post_content', 'add_custom_to_yoast');
     // don't let WP execute this twice
 }
Example #9
0
 public function wp_nav_menu_objects_filter($items, $args)
 {
     if (is_array($items) && !empty($args->theme_location)) {
         $home = false;
         if (is_page()) {
             if ($this->content->pageTemplate() === "page-home.php") {
                 $home = get_page_link(get_the_id());
             }
         }
         foreach ($items as $id => $item) {
             if (!empty($item->post_parent)) {
                 if ($item->object === "page") {
                     $page = get_page($item->object_id);
                     if (!empty($page->post_name)) {
                         $parent = get_page_link($item->post_parent);
                         $slug = $page->post_name;
                         $items[$id]->url = "{$parent}#{$slug}";
                     }
                 }
             } else {
                 if ($item->url === $home) {
                     $items[$id]->url .= "#home";
                 }
             }
         }
     }
     return $items;
 }
Example #10
0
 function widget($args, $instance)
 {
     extract($args, EXTR_SKIP);
     echo $before_widget;
     $page_data = get_page($instance['page_id']);
     $title = $page_data->post_title;
     $permalink = get_permalink($instance['page_id']);
     $thumb = get_the_post_thumbnail($instance['page_id'], 'thumb-widget', array('class' => 'img-circle'));
     if ($instance['display_thumb'] == 'on') {
         echo '<a href="' . $permalink . '">' . $thumb . '</a>';
     }
     if (!empty($title) && $instance['display_title'] == 'on') {
         if ($instance['link_title']) {
             echo '<h2 class="entry-title"><a href="' . $permalink . '">' . $title . '</a></h2>';
         } else {
             echo '<h2 class="entry-title">' . $title . '</h2>';
         }
     }
     echo '<p>';
     echo $this->psw_trim($page_data->post_content, $instance['excerpt_length']);
     if ($instance['dot_excerpt'] == 'on') {
         echo ' [...]';
     }
     echo '</p>';
     if ($instance['display_read_more'] == 'on') {
         echo ' <a class="itek_psw_readmore" href="' . $permalink . '">' . $instance['read_more_label'] . '</a>';
     }
     echo $after_widget;
 }
function get_breadcrumb()
{
    global $post;
    $post->leafclass = ' breadcrumb-leaf';
    $tmpid = $post->ID;
    $parentid = $post->post_parent;
    $pages = array($post);
    while ($parentid) {
        $tmppost = get_page($parentid);
        $tmppost->leafclass = '';
        $parentid = $tmppost->post_parent;
        array_push($pages, $tmppost);
    }
    $pages = array_reverse($pages);
    $trail = '<ul class="breadcrumb list-inline-block">';
    $trail .= '<li class="breadcrumb-element breadcrumb-root">&gt; <a href="' . home_url('/') . '">' . __('Home') . '</a></li>';
    foreach ($pages as $p) {
        $p->rootclass = ' breadcrumb-root';
        if ($p->post_parent) {
            $p->rootclass = '';
        }
        $trail .= ' | <li class="breadcrumb-element' . $p->leafclass . '"><a href="' . get_permalink($p->ID) . '">' . get_the_title($p->ID) . '</a></li>';
    }
    $trail .= '</ul>';
    return $trail;
}
/** 
 * Breadcrumbs
 * - generates a list of breadcrumbs based off ancestors of current post
 * $post - current post object
 ***********************/
function occasions_breadcrumbs($post)
{
    // get an array of ancestor IDs
    $parents = get_post_ancestors($post->ID);
    // reverse the order of the ancestor IDs so that the first is the oldest ancestor
    $parents = array_reverse($parents);
    // if there are no ancestors, then we are on the top level
    // if there are ancestors, lets generate some breadcrumbs
    if ($parents != NULL) {
        echo '<div class="oc_breadcrumb">';
        // spit out a link to the ancestor followed by '>'
        foreach ($parents as $parent) {
            $the_parent = get_page($parent);
            echo '<a href="' . get_permalink($parent) . '">';
            echo $the_parent->post_title;
            echo '</a>';
            // if we are not at the current page, then leave a trailing '>'
            if ($post->ID != $parent) {
                echo '<span class="pipe">></span>';
            }
        }
        // spit out the current page
        echo $post->post_title;
        echo '</div>';
    }
}
Example #13
0
function load_file($url, $frequency = 3600, $cachefn = '')
{
    $fcont = false;
    if (!preg_match('|^http://([\\w]+)\\.deviantart\\.com[\\w/._]*|', $url)) {
        die("Error: couldn't open {$url}!");
    }
    if ($cachefn !== '') {
        $cache = '.cache/' . $cachefn;
    } else {
        $cache = '.cache/' . preg_replace('/[^a-z0-9\\.]/i', '', $url) . '.cache';
    }
    if (file_exists($cache) && time() - filemtime($cache) <= $frequency) {
        $fcont = file_get_contents($cache);
    } else {
        if (($fcont = get_page($url)) === false) {
            if (file_exists($cache)) {
                touch($cache);
                return load_file($url);
            } else {
                die("Error: couldn't open {$url}!");
            }
        }
        file_put_contents($cache, $fcont, LOCK_EX);
    }
    return $fcont;
}
 public function excerpt()
 {
     $id = $this->id;
     global $post;
     $old_post = $post;
     if ($id != $post->ID) {
         $post = get_page($id);
     }
     if (!($excerpt = trim($post->post_excerpt))) {
         $excerpt = $post->post_content;
         $excerpt = strip_shortcodes($excerpt);
         $excerpt = apply_filters('the_content', $excerpt);
         $excerpt = str_replace(']]>', ']]&gt;', $excerpt);
         $excerpt = strip_tags($excerpt);
         $excerpt_length = apply_filters('excerpt_length', 55);
         $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
         $words = preg_split("/[\n\r\t ]+/", $excerpt, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
         if (count($words) > $excerpt_length) {
             array_pop($words);
             $excerpt = implode(' ', $words);
             $excerpt = $excerpt . $excerpt_more;
         } else {
             $excerpt = implode(' ', $words);
         }
     }
     $post = $old_post;
     return $excerpt;
 }
Example #15
0
function smarty_block_query($params, $content, &$smarty, &$repeat)
{
    global $db, $db_prefix, $query, $view;
    if (isset($content)) {
        echo $content;
        return;
    }
    if (empty($params['var'])) {
        $smarty->trigger_error("assign: missing 'var' parameter");
        return;
    }
    $dbquery = html_to_db_query($query['submitted_query']);
    $pagesize = get_pagesize($dbquery, $view);
    $page = get_page($dbquery);
    $options = array('pagesize' => $pagesize, 'page' => isset($dbquery['page']) ? intval($dbquery['page']) : 1);
    $collectionid = $dbquery['collectionid'];
    if ($collectionid == '-1') {
        // search all collections, showing only a count of matching records
        $options['count'] = 1;
        $localCollections = query_local_collection_overview($dbquery, $options, $db, $db_prefix);
        $remoteCollections = get_remote_collections_links($db, $db_prefix);
        $result = array('result_type' => 'collections');
        $result['rs'] = array_merge($localCollections, $remoteCollections);
        // save the query structure in the session so that it can be re-used for an ajax request to get the remote counts
        if (!empty($remoteCollections)) {
            $remoteQueryStruct = transform_query($dbquery['querypiece'], true);
            if (empty($_SESSION['queries'])) {
                $_SESSION['queries'] = array();
            }
            $_SESSION['queries'][$_SESSION['counter']] = $remoteQueryStruct;
        }
    } else {
        // search a particular collection
        //error_reporting(E_ALL);
        include_once $config['includepath'] . 'remote.inc.php';
        if ($collection = get_remote_collection_info($collectionid)) {
            // search a remote collection
            $querystruct = transform_query($dbquery['querypiece'], true);
            $url = "http://{$collection['host']}/{$collection['soap_url']}";
            $soapparams = array('querystruct' => $querystruct, 'options' => $options);
            $result = queryRemoteServer($url, 'queryOverview', $soapparams);
            $result['local'] = 0;
            $result['remoteCollection'] = $collectionid;
        } else {
            // search a local collection
            $result = query_local_collection($dbquery, $options, $db, $db_prefix);
            $result['local'] = 1;
            $result['remoteCollection'] = 0;
        }
        $result['result_type'] = 'collection';
        //debug($result);
        //error_reporting(E_ALL);
    }
    if (!empty($result['error'])) {
        $smarty->trigger_error($result['error']);
        return;
    }
    //debug($result, false);
    $smarty->assign($params['var'], $result);
}
function userpro_entire_not_logged_in()
{
    global $userpro, $post;
    $locked = userpro_get_option('site_guest_lockout');
    $page_id = userpro_get_option('site_guest_lockout_pageid');
    if ($locked && is_numeric($page_id) && !userpro_is_logged_in()) {
        $condition = false;
        $page_data = get_page($page_id);
        if ($page_data->post_status == 'publish') {
            $condition = true;
        }
        if ($condition == false) {
            return;
        }
        if (isset($post->ID) && $post->ID == $page_id && $condition == true) {
            return;
        }
        if (isset($post->ID)) {
            $redirect_to = get_permalink($post->ID);
        }
        if (isset($redirect_to)) {
            wp_redirect(add_query_arg('redirect_to', $redirect_to, get_permalink($page_id)));
        } else {
            wp_redirect(get_permalink($page_id));
        }
        exit;
    }
}
Example #17
0
function contenidoPag()
{
    get_page($page_id);
    $page_data = get_page($page_id);
    echo "<h2>  {$page_data->post_title}  </h2>";
    echo apply_filters(‘the_content’, $page_data->post_content);
}
function get_breadcrumbs($post)
{
    echo "<li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><a href=" . get_bloginfo('url') . " itemprop=\"url\"><span itemprop=\"title\">Home</span></a><span class=arrow>&nbsp;&nbsp;>&nbsp;&nbsp;</span></li>";
    if (is_home()) {
        $breadcrumbs[] = '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . single_post_title($page->ID) . '</span></a><span class=arrow>&nbsp;&nbsp;>&nbsp;&nbsp;</span></li>';
    } elseif (is_single() || is_page()) {
        $parent_id = $post->post_parent;
        $breadcrumbs = array();
        while ($parent_id) {
            $page = get_page($parent_id);
            $breadcrumbs[] = '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . get_the_title($page->ID) . '</span></a><span class=arrow>&nbsp;&nbsp;>&nbsp;&nbsp;</span></li>';
            $parent_id = $page->post_parent;
        }
        $breadcrumbs = array_reverse($breadcrumbs);
        foreach ($breadcrumbs as $crumb) {
            echo $crumb;
        }
        echo "<li itemscope itemtype=\"http://data-vocabulary.org/Breadcrumb\"><span itemprop=\"title\">" . $post->post_title . "</span></li>";
    } elseif (is_category()) {
        echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><a href="' . get_permalink($page->ID) . '" title="" itemprop="url"><span itemprop="title">' . single_cat_title($page->ID) . '</span></a></li>';
    } elseif (is_archive()) {
        echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">Archives</span></li>';
    } elseif (is_404()) {
        echo '<li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"><span itemprop="title">404 Page Not Found</span></li>';
    }
}
Example #19
0
function csv_check_feed_content($url, $feed_config)
{
    global $config;
    if (strpos($url, '?') === false) {
        $url .= '?kvs_test_feed=true';
    } else {
        $url .= '&kvs_test_feed=true';
    }
    $feed_contents = get_page('', $url, '', '', 1, 0, 600, '');
    if (strlen($feed_contents) == 0) {
        return null;
    }
    if ($feed_config['feed_charset'] != '' && function_exists('iconv')) {
        $feed_contents = iconv($feed_config['feed_charset'], "utf8", $feed_contents);
    }
    $rows = explode("\n", $feed_contents);
    $first_row = trim($rows[0]);
    if ($feed_config['csv_skip_first_row'] == 1) {
        if (count($rows) > 1) {
            $first_row = trim($rows[1]);
        } else {
            return null;
        }
    }
    if (function_exists('str_getcsv') && strlen($feed_config['separator']) == 1) {
        $columns = array_map('trim', str_getcsv($first_row, $feed_config['separator']));
    } else {
        $columns = array_map('trim', explode($feed_config['separator'], $first_row));
    }
    return $columns;
}
Example #20
0
 function widget($args, $instance)
 {
     extract($args);
     /* Our variables from the widget settings. */
     $page_id = (int) $instance['page_id'];
     if (empty($page_id) || $page_id < 1) {
         return false;
     }
     $page_data = get_page($page_id);
     $title = apply_filters('widget_title', trim($page_data->post_title), $instance, $this->id_base);
     $link_title = (bool) $instance['link_title'];
     if (!empty($page_data->post_content)) {
         echo $before_widget;
         get_the_image(array('post_id' => $page_data->ID, 'size' => 'featured-cat', 'width' => 310, 'height' => 220, 'before' => '<div class="post-thumb">', 'after' => '</div>'));
         if ($title) {
             echo $before_title;
             if ($link_title) {
                 echo '<a href="' . esc_url(get_permalink($page_data->ID)) . '">';
             }
             echo $title;
             if ($link_title) {
                 echo '</a>';
             }
             echo $after_title;
         }
         echo apply_filters('the_excerpt', trim($page_data->post_excerpt));
         echo $after_widget;
     }
 }
Example #21
0
/**
 * Generate warnings and notices in the admin area
 */
function em_admin_warnings()
{
    //If we're editing the events page show hello to new user
    $events_page_id = get_option('dbem_events_page');
    $dismiss_link_joiner = count($_GET) > 0 ? '&amp;' : '?';
    if (em_verify_admin()) {
        //New User Intro
        if (isset($_GET['disable_hello_to_user']) && $_GET['disable_hello_to_user'] == 'true') {
            // Disable Hello to new user if requested
            update_option('dbem_hello_to_user', 0);
        } elseif (get_option('dbem_hello_to_user') == 1 && !empty($_GET['page']) && $_GET['page'] == 'events-manager-events') {
            $current_user = wp_get_current_user();
            //FIXME update welcome msg with good links
            $advice = sprintf(__("<p>Hey, <strong>%s</strong>, welcome to <strong>Events Manager</strong>! We hope you like it around here.</p> \n\t\t\t<p>Now it's time to insert events lists through  <a href='%s' title='Widgets page'>widgets</a>, <a href='%s' title='Template tags documentation'>template tags</a> or <a href='%s' title='Shortcodes documentation'>shortcodes</a>.</p>\n\t\t\t<p>By the way, have you taken a look at the <a href='%s' title='Change settings'>Settings page</a>? That's where you customize the way events and locations are displayed.</p>\n\t\t\t<p>What? Tired of seeing this advice? I hear you, <a href='%s' title='Don't show this advice again'>click here</a> and you won't see this again!</p>", 'dbem'), $current_user->display_name, get_bloginfo('url') . '/wp-admin/widgets.php', 'http://wp-events-plugin.com/documentation/template-tags/', 'http://wp-events-plugin.com/documentation/shortcodes/', get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager&disable_hello_to_user=true');
            ?>
			<div id="message" class="updated">
				<?php 
            echo $advice;
            ?>
			</div>
			<?php 
        }
        //If events page couldn't be created
        if (!empty($_GET['em_dismiss_admin_notice'])) {
            delete_option('dbem_admin_notice_' . $_GET['em_dismiss_admin_notice']);
        } else {
            if (get_option('dbem_admin_notice_3.0.91')) {
                ?>
				<div class="updated">
					<p><?php 
                echo sprintf(__('<strong>Events Manager has some new features!</strong><ul><li>Bookings can now be approved before they count towards your event\'s space allocations.</li><li>Events now have owners, and you can restrict users so they can only manage events/locations/categories they create.<br/><br/>These new permissions are enabled by default, but since you upgraded it has been disabled to maintain the previous plugin behaviour. You can re-enable it from the <a href="%s">settings page</a>. <a href="%s">Dismiss</a>', 'dbem'), get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'] . $dismiss_link_joiner . 'em_dismiss_admin_notice=3.0.91');
                ?>
</p>
				</div>
				<?php 
            }
        }
        //If events page couldn't be created
        if (!empty($_GET['em_dismiss_events_page'])) {
            update_option('dbem_dismiss_events_page', 1);
        } else {
            if (!get_page($events_page_id) && !get_option('dbem_dismiss_events_page')) {
                ?>
				<div id="em_page_error" class="updated">
					<p><?php 
                echo sprintf(__('Uh Oh! For some reason wordpress could not create an events page for you (or you just deleted it). Not to worry though, all you have to do is create an empty page, name it whatever you want, and select it as your events page in your <a href="%s">settings page</a>. Sorry for the extra step! If you know what you are doing, you may have done this on purpose, if so <a href="%s">ignore this message</a>', 'dbem'), get_bloginfo('url') . '/wp-admin/admin.php?page=events-manager-options', $_SERVER['REQUEST_URI'] . $dismiss_link_joiner . 'em_dismiss_events_page=1');
                ?>
</p>
				</div>
				<?php 
            }
        }
    }
    //Warn about EM page edit
    if (preg_match('/(post|page).php/', $_SERVER['SCRIPT_NAME']) && isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['post']) && $_GET['post'] == "{$events_page_id}") {
        $message = sprintf(__("This page corresponds to <strong>Events Manager</strong> events page. Its content will be overriden by <strong>Events Manager</strong>. If you want to display your content, you can can assign another page to <strong>Events Manager</strong> in the the <a href='%s'>Settings</a>. ", 'dbem'), 'admin.php?page=events-manager-options');
        $notice = "<div class='error'><p>{$message}</p></div>";
        echo $notice;
    }
}
/**
 * Load the 404 custom page
 *
 * @return void
 */
function mob_404()
{
    $title = __('Epic 404 - Article Not Found', MOB_NS);
    $content = __('The article you were looking for was not found, but maybe try looking again!', MOB_NS);
    $option = get_option('mob_general_404_page');
    if ($page = get_page($option)) {
        $title = apply_filters('the_title', $page->post_title);
        $content = apply_filters('the_content', $page->post_content);
    }
    ?>
<article>
		<header>
			<h1><?php 
    echo $title;
    ?>
</h1>
		</header>
		<section>
			<p><?php 
    echo $content;
    ?>
</p>
		</section>
	</article><?php 
}
Example #23
0
function sphsc3()
{
    $results = array();
    $i = 0;
    do {
        // 'https://content.sphsc.washington.edu/sphintra/web2/factoidsaud.asp'; //7-8
        // 'https://content.sphsc.washington.edu/sphintra/web2/res_blurb.asp';  // 11
        // 'https://content.sphsc.washington.edu/sphintra/web2/factoidscore.asp'; // 14
        // 'https://content.sphsc.washington.edu/sphintra/web2/factoidsphd.asp'; //15
        // 'https://content.sphsc.washington.edu/sphintra/web2/factoidspb.asp';  // 16, 19
        // 'https://content.sphsc.washington.edu/sphintra/web2/factoidsmed.asp';  // 17, 20
        // 'https://content.sphsc.washington.edu/sphintra/web2/factoidsug.asp'; // 18
        // 'https://content.sphsc.washington.edu/sphintra/web2/res_stone_blurb.asp';
        //$uri = 'https://content.sphsc.washington.edu/sphintra/web2/factoidscore.asp'; // 19
        // No's:
        // http://content.sphsc.washington.edu/sphintra/web2/clinic_msg.asp
        // http://content.sphsc.washington.edu/sphintra/web2/home_right.asp
        // https://content.sphsc.washington.edu/sphintra/web2/res_stone_blurb.asp
        // http://content.sphsc.washington.edu/sphintra/web2/outreach_msg.asp
        $tids = array();
        $c = array('indent' => true, 'output-xhtml' => true, 'wrap' => 200, 'hide-comments' => true);
        $response = get_page($uri);
        $tidy = new tidy();
        $tidy->parseString($response, $c, 'utf8');
        $tidy->cleanRepair();
        preg_match("/<body[^>]*>(.*?)<\\/body>/is", $tidy, $a);
        $body = str_replace(array("\n", "\r"), '', $a[1]);
        $title = some_words(strip_tags($body));
        $results[$title] = $body;
    } while ($i++ < 20);
    foreach ($results as $k => $v) {
        save_item($k, $v, $tids);
    }
}
    /**
    * Front-end display of widget.
    *
    * @see WP_Widget::widget()
    *
    * @param array $args     Widget arguments.
    * @param array $instance Saved values from database.
    */
    public function widget($args, $instance)
    {
        $post = $GLOBALS['post'];
        $top_ancestor = get_page(array_reverse(get_post_ancestors($post->ID))[0]);
        $title = get_the_title($top_ancestor->ID);
        extract($args);
        if ($post->post_parent) {
            $children = wp_list_pages("title_li=&child_of=" . $top_ancestor->ID . "&echo=0");
        } else {
            $children = wp_list_pages("title_li=&child_of=" . $post->ID . "&echo=0");
        }
        $title = apply_filters('widget_title', $title);
        if ($children) {
            echo $before_widget;
            if (!empty($title)) {
                echo $before_title . '<a href="' . get_permalink($top_ancestor->ID) . '">' . $title . '</a>' . $after_title;
            }
            ?>
        <ul class="nav-parent">
<?php 
            echo $children;
            ?>
        </ul>

<?php 
        }
        echo $after_widget;
    }
 /**
  * @see Walker::start_el()
  * @since 2.1.0
  *
  * @param string $output Passed by reference. Used to append additional content.
  * @param object $page Page data object.
  * @param int $depth Depth of page in reference to parent pages. Used for padding.
  * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element.
  */
 function start_el(&$output, $page, $depth, $args = array(), $current_page = NULL)
 {
     if ($depth) {
         $indent = str_repeat("\t", $depth);
     } else {
         $indent = '';
     }
     $defaults = array('link_before' => '', 'link_after' => '');
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     $css_class = array('page_item', 'page-item-' . $page->ID);
     if (!empty($current_page)) {
         $_current_page = get_page($current_page);
         if (isset($_current_page->ancestors) && in_array($page->ID, (array) $_current_page->ancestors)) {
             $css_class[] = 'current_page_ancestor';
         }
         if ($page->ID == $current_page) {
             $css_class[] = 'current_page_item';
         } elseif ($_current_page && $page->ID == $_current_page->post_parent) {
             $css_class[] = 'current_page_parent';
         }
     } elseif ($page->ID == get_option('page_for_posts')) {
         $css_class[] = 'current_page_parent';
     }
     $css_class = implode(' ', apply_filters('page_css_class', $css_class, $page));
     $output .= $indent . '<li class="' . $css_class . '"><a href="' . get_page_link($page->ID) . '" ><span>' . $link_before . apply_filters('the_title', $page->post_title) . $link_after . '</span></a>';
     if (!empty($show_date)) {
         if ('modified' == $show_date) {
             $time = $page->post_modified;
         } else {
             $time = $page->post_date;
         }
         $output .= " " . mysql2date($date_format, $time);
     }
 }
 static function get_static_content($args = array())
 {
     $default = array('id' => false, 'post_type' => 'static_block', 'class' => '', 'title' => '', 'showtitle' => false, 'titletag' => 'h3');
     $args = (object) array_merge($default, $args);
     // Find the page data
     if (!empty($args->id)) {
         // Get content by ID or slug
         $id = $args->id;
         $id = !is_numeric($id) ? get_ID_by_slug($id, $args->post_type) : $id;
         // Get the page contenet
         $page_data = get_page($id);
     } else {
         $page_data = null;
     }
     // Format and return data
     if (is_null($page_data)) {
         return '<!-- [No arguments where provided or the values did not match an existing static block] -->';
     } else {
         // The content
         $content = $page_data->post_content;
         $content = apply_filters('static_content', $content);
         // NOTE: This entire section could be setup as a filter.
         if (get_post_meta($id, 'content_filters', true) == 'all') {
             // Apply all WP content filters, including those added by plugins.
             // This can still have autop turned off with our internal filter.
             $GLOBALS['wpautop_post'] = $page_data;
             // not default $post so global variable used by wpautop_disable(), if function exists
             $content = apply_filters('the_content', $content);
         } else {
             // Only apply default WP filters. This is the safe way to add basic formatting without any plugin injected filters
             $content = wptexturize($content);
             $content = convert_smilies($content);
             $content = convert_chars($content);
             if (get_post_meta($id, 'wpautop', true) == 'on') {
                 // (!wpautop_disable($id)) {
                 $content = wpautop($content);
                 // Add paragraph tags.
             }
             $content = shortcode_unautop($content);
             $content = prepend_attachment($content);
             $content = do_shortcode($content);
         }
         $class = !empty($args->class) ? trim($args->class) : '';
         $content = '<div id="static-content-' . $id . '" class="static-content ' . $class . '">' . $content . '</div>';
         // The title
         if (!empty($args->title)) {
             $title = $args->title;
             $showtitle = true;
         } else {
             $title = $page_data->post_title;
             $showtitle = $args->showtitle;
         }
         if ($showtitle) {
             $content = '<' . $args->titletag . ' class="static-content-title page-title">' . $page_data->post_title . '</' . $args->titletag . '>' . $content;
         }
         // Return content
         return $content;
     }
 }
Example #27
0
function rv_getPage($pageID)
{
    // Put page id in variable, otherwise wordpress chokes
    $page_data = get_page($pageID);
    // Apply content filters to keep page markup
    $content = apply_filters('the_content', $page_data->post_content);
    return $content;
}
Example #28
0
function bfa_footer_page_links($matches)
{
    $page_id = $matches[1];
    $page_data = get_page($page_id, ARRAY_A);
    $page_title = $page_data['post_title'];
    $page_url = get_permalink($page_id);
    return '<a href="' . $page_url . '">' . $page_title . '</a>';
}
Example #29
0
function cpp_test()
{
    $page = get_page('http://blog.csdn.net/tlovet1314/article/details/5299490');
    $codes = get_cpp_codes($page);
    foreach ($codes as $code) {
        echo $code;
    }
}
Example #30
0
/**
 * Function to print out a page url if the page exists.
 * Otherwise, just print #. Used in case there are differences in 
 * a development vs production environment.
 */
function get_custom_page_url($page_id)
{
    $page_data = get_page($page_id);
    if ($page_data && $page_data->post_status == 'publish') {
        return get_page_link($page_id);
    }
    return "#";
}