Exemple #1
0
function limit_posts_per_archive_page()
{
    if (is_category(31)) {
        set_query_var('posts_per_archive_page', 5);
    }
    // or use variable key: posts_per_page
}
 public function index($page = 1)
 {
     global $paged;
     $page_id = get_option('page_for_posts');
     if ($page < 0) {
         $page = 1;
     }
     set_query_var('paged', $page);
     if ($page_id > 0) {
         $layout = get_post_meta($page_id, '_layout', true);
         if (empty($layout) || !$this->view->check_layout($layout)) {
             $layout = $this->core->get_option('blog_layout', 'content_right');
         }
         $page_title = get_the_title($page_id);
         $page_tagline = get_post_meta($page_id, '_page_tagline', true);
         if (!get_post_meta($page_id, '_disable_page_title', true)) {
             $this->view->add_block('page_title', 'general/page_title', array('page_title' => $page_title, 'page_tagline' => $page_tagline));
         }
         if (!get_post_meta($page_id, '_disable_breadcrumbs', true)) {
             $this->breadcrumbs->add_item($page_title . ' ' . $page_tagline, get_permalink($page_id));
         }
     } else {
         // THEME SETTINGS
         $this->view->add_block('page_title', 'general/page_title', array('page_title' => $this->core->get_option('blog_title')));
         $layout = $this->core->get_option('blog_layout', 'content_right');
     }
     //$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
     $paginator = $this->load->library('paginator');
     $paginator = $paginator->get(3, wp_count_posts()->publish, get_option('posts_per_page'), 1, 2, 'blog/page/' . $page, 'blog/');
     $this->view->use_layout('header_' . $layout . '_footer')->add_block('content', 'blog/view', array('layout' => $layout))->add_block('content/pagination', 'general/pagination', $paginator);
 }
Exemple #3
0
    public function getLastPosts($atts)
    {
        extract(shortcode_atts(array('kategorie' => 'post', 'anzahl' => 3, 'zeichen' => 250), $atts));
        global $wpdb;
        $sql = 'SELECT p.ID, p.post_title, p.guid, p.post_content
				FROM ' . $wpdb->prefix . 'terms
					INNER JOIN ' . $wpdb->prefix . 'term_taxonomy ON ' . $wpdb->prefix . 'terms.term_id = ' . $wpdb->prefix . 'term_taxonomy.term_id
					INNER JOIN ' . $wpdb->prefix . 'term_relationships AS wpr ON wpr.term_taxonomy_id = ' . $wpdb->prefix . 'term_taxonomy.term_taxonomy_id
					INNER JOIN ' . $wpdb->prefix . 'posts AS p ON p.ID = wpr.object_id
				WHERE p.post_type = "post"
					AND ' . $wpdb->prefix . 'term_taxonomy.taxonomy = "category"
					AND ' . $wpdb->prefix . 'terms.name = "' . $kategorie . '"
					AND p.post_status = "publish"
				ORDER BY p.post_date
				DESC LIMIT ' . $anzahl;
        $result = $wpdb->get_results($sql);
        $lastPosts = array();
        if ($result) {
            foreach ($result as $key => $row) {
                if ((int) $zeichen === 0) {
                    $row->read_more = 0;
                } else {
                    $postContent = strip_tags($row->post_content);
                    //Alle HTML Tags entfernen. Nur reinen Text anzeigen lassen.
                    $row->post_content = substr($postContent, 0, $zeichen);
                    //Ausgabe begrenzen
                    $row->read_more = 1;
                }
                set_query_var('singlePost', $row);
                get_template_part('partials/single');
            }
        }
    }
    public function render($properties)
    {
        ?>
		<div class="module module--padded">



		<?php 
        $moduleIdentifier = "selectedModules_" . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90)) . chr(rand(65, 90));
        $fagmod = new Fagmoduler();
        if (is_page_template('gode-erfaringer-children.php')) {
            $field_fornavn = get_field('fornavn', get_the_ID());
            if ($field_fornavn) {
                print '<h3>' . $properties['headline'] . ' som ' . $field_fornavn . '</h3>';
            } else {
                print '<h3>' . $properties['headline'] . '</h3>';
            }
        } else {
            print '<h2>' . $properties['headline'] . '</h2>';
        }
        $fagList = array();
        foreach ($properties['modules'] as $modul) {
            $f*g = $fagmod->getFag(get_field("fag_id", $modul['module_post']->ID));
            $fagList[] = $f*g;
        }
        ?>



		<script>
			var <?php 
        print $moduleIdentifier;
        ?>
 = <?php 
        print json_encode($fagList);
        ?>
;
		</script>
	
		<div class="accordion accordion--trade panel-group" ng-controller="SelectedModulesCtrl as <?php 
        print $moduleIdentifier;
        ?>
" ng-init="<?php 
        print $moduleIdentifier;
        ?>
.init('<?php 
        print $moduleIdentifier;
        ?>
')">
			<?php 
        set_query_var('moduleIdentifier', $moduleIdentifier);
        get_template_part('parts/fagmoduler-accordion-part');
        ?>
		</div>



		</div>
		<?php 
    }
 public function wp(WP $WP)
 {
     if (is_404() && ($class_name = $this->get_404_class_name())) {
     } elseif (is_search() && ($class_name = $this->get_search_class_name())) {
     } elseif (is_front_page() && ($class_name = $this->get_front_page_class_name())) {
     } elseif (is_home() && ($class_name = $this->get_home_class_name())) {
     } elseif (is_post_type_archive() && ($class_name = $this->get_post_type_archive_class_name())) {
     } elseif (is_tax() && ($class_name = $this->get_taxonomy_class_name())) {
         //        elseif (is_attachment() && $class_name = $this->get_attachment_class_name()):
     } elseif (is_page() && ($class_name = $this->get_page_class_name())) {
     } elseif (is_single() && ($class_name = $this->get_single_class_name())) {
     } elseif (is_category() && ($class_name = $this->get_category_class_name())) {
     } elseif (is_tag() && ($class_name = $this->get_tag_class_name())) {
     } elseif (is_author() && ($class_name = $this->get_author_class_name())) {
     } elseif (is_date() && ($class_name = $this->get_date_class_name())) {
         //        elseif (is_comments_popup() && $class_name = $this->get_comments_popup_class_name()):
         //        elseif (is_paged() && $class_name = $this->get_paged_class_name()):
     } else {
         $class_name = $this->get_index_class_name();
     }
     // must use Autoloader
     if ($class_name && class_exists($class_name)) {
         set_query_var($this->class_data['store_name'], new $class_name());
     }
     return;
 }
function changept()
{
    if (is_category() && !is_admin()) {
        set_query_var('post_type', array('post', 'category'));
    }
    return;
}
 /**
  * @usage Short-code function for front-end UI
  * @return string
  */
 function Dashboard()
 {
     global $current_user;
     wp_reset_query();
     $currentAccess = maybe_unserialize(get_option('__wpdm_front_end_access', array()));
     $task = get_query_var('adb_page');
     $task = explode("/", $task);
     if ($task[0] == 'edit-package') {
         $pid = $task[1];
     }
     if ($task[0] == 'page') {
         $task[0] = '';
         set_query_var('paged', $task[1]);
     }
     $task = $task[0];
     if (!array_intersect($currentAccess, $current_user->roles) && is_user_logged_in()) {
         return "<div class='w3eden'><div class='alert alert-danger'>" . wpautop(stripslashes(get_option('__wpdm_front_end_access_blocked', __('Sorry, Your Are Not Allowed!', 'wpdmpro')))) . "</div></div>";
     }
     $id = wpdm_query_var('ID');
     $tabs = array();
     $tabs = apply_filters('wpdm_frontend', $tabs);
     $burl = get_permalink();
     $sap = strpos($burl, '?') ? '&' : '?';
     ob_start();
     include \WPDM\Template::Locate('author-dashboard.php');
     $data = ob_get_clean();
     return $data;
 }
 public static function process()
 {
     theme_features::check_referer();
     $post_id = isset($_GET['post-id']) && is_numeric($_GET['post-id']) ? (int) $_GET['post-id'] : false;
     if (!$post_id) {
         die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_post_id', 'msg' => ___('Sorry, post id is invaild.')]));
     }
     global $post, $page;
     /**
      * post
      */
     $post = theme_cache::get_post($post_id);
     if (!$post) {
         die(theme_features::json_format(['status' => 'error', 'code' => 'post_not_exist', 'msg' => ___('Sorry, the post does not exist.')]));
     }
     /**
      * page
      */
     $page = isset($_GET['page']) && is_numeric($_GET['page']) ? (int) $_GET['page'] : false;
     if (!$page) {
         die(theme_features::json_format(['status' => 'error', 'code' => 'invaild_page_number', 'msg' => ___('Sorry, page number is invaild.')]));
     }
     set_query_var('page', $page);
     setup_postdata($post);
     ob_start();
     if (class_exists('theme_img_lazyload')) {
         remove_filter('the_content', 'theme_img_lazyload::the_content');
     }
     the_content();
     $content = html_minify(ob_get_contents());
     ob_end_clean();
     die(theme_features::json_format(['status' => 'success', 'content' => $content]));
 }
 public function testThePosts()
 {
     global $wp_query;
     $this->assertNull($this->frontend->thePosts(null));
     set_query_var('is_search', false);
     $posts = array();
     $posts[] = new WP_Post();
     $posts[] = new WP_Post();
     $this->assertEquals($this->frontend->thePosts($posts), $posts);
     set_query_var('is_search', true);
     set_query_var('is_admin', true);
     $this->assertEquals($this->frontend->thePosts($posts), $posts);
     set_query_var('is_search', true);
     set_query_var('is_admin', false);
     $this->assertNotEquals($this->frontend->thePosts($posts), $posts);
     $post = new WP_Post();
     $post->ID = 3;
     $posts = array($post);
     set_query_var('is_main_query', true);
     $wp_query->is_main_query = true;
     $wp_query->is_search = true;
     $wp_query->is_admin = false;
     $wp_query->query['s'] = 'aliyun';
     $this->aliyunOpenSearchClient->shouldReceive('search')->andReturn(array('posts' => $posts, 'total' => 1))->once();
     $this->frontend->preGetPosts($wp_query);
     $this->assertEquals($this->frontend->thePosts($posts), $posts);
 }
    /**
     * Display related posts
     */
    public function display()
    {
        $posts = $this->get_related_posts();
        if (empty($posts)) {
            return;
        }
        global $post, $wp_query;
        $default_query = clone $wp_query;
        set_query_var('is_related', true);
        ?>
		<div class="related-posts">
			<h2 class="related-posts__title h3"><?php 
        _e('Related posts', 'habakiri');
        ?>
</h2>
			<div class="entries entries--related-posts entries-related-posts">
				<?php 
        foreach ($posts as $post) {
            setup_postdata($post);
            get_template_part('content', 'summary');
        }
        wp_reset_postdata();
        ?>
			</div>
		</div>
		<?php 
        $wp_query = $default_query;
    }
function nimbus_cotizador($atts, $content)
{
    extract($atts);
    set_query_var('success', $action);
    $template = locate_template("/templates/quote.php");
    load_template($template);
}
Exemple #12
0
/**
 * Filter archives to display one less post per page to account for the .page-title circle
 */
function spun_limit_posts_per_archive_page()
{
    if (!is_home() && is_archive() || is_search()) {
        $posts_per_page = intval(get_option('posts_per_page')) - 1;
        set_query_var('posts_per_page', $posts_per_page);
    }
}
 function wpex_blog_exclude_categories()
 {
     // Wait..we don't want to be in these plages? Lets leave now!
     if (is_admin()) {
         return;
     }
     if (is_search()) {
         return;
     }
     if (is_archive()) {
         return;
     }
     // Categories to exclude
     $cats_to_exclude = wpex_option('blog_cats_exclude');
     // Admin option is blank, so bail.
     if ($cats_to_exclude == '') {
         return;
     }
     // Blog template
     if (is_home() && !is_singular('page')) {
         $exclude = $cats_to_exclude;
     } else {
         return;
         // Do nothing, ok?
     }
     if ($cats_to_exclude) {
         set_query_var('category__not_in', $cats_to_exclude);
     }
 }
 function widget($args, $instance)
 {
     // Turn $args array into variables.
     extract($args);
     // $instance Defaults
     $instance_defaults = $this->defaults;
     // Parse $instance
     $instance = wp_parse_args($instance, $instance_defaults);
     // Options output
     $section_title = !empty($instance['title']) ? $instance['title'] : '';
     set_query_var('section_title', strip_tags($section_title));
     $spo = !empty($instance['show_pos']) ? 1 : 0;
     set_query_var('spo', absint($spo));
     $sco = !empty($instance['show_com']) ? 1 : 0;
     set_query_var('sco', absint($sco));
     $sca = !empty($instance['show_cat']) ? 1 : 0;
     set_query_var('sca', absint($sca));
     $sda = !empty($instance['show_date']) ? 1 : 0;
     set_query_var('sda', absint($sda));
     $cnmt = !empty($instance['css_no_mt']) ? 1 : 0;
     $cnmb = !empty($instance['css_no_mb']) ? 1 : 0;
     $cbot = !empty($instance['css_b_top']) ? 1 : 0;
     $cbob = !empty($instance['css_b_bot']) ? 1 : 0;
     $cpat = !empty($instance['css_p_top']) ? 1 : 0;
     // Widget styling based on options
     $css_class = array();
     if ($cnmt) {
         $css_class[] = 'n-mt';
     }
     if ($cnmb) {
         $css_class[] = 'n-mb';
     }
     if ($cbot) {
         $css_class[] = 'b-top';
     }
     if ($cbob) {
         $css_class[] = 'b-bot';
     }
     if ($cpat) {
         $css_class[] = 'p-top';
     }
     $css_classes = join(' ', $css_class);
     if (!empty($css_classes)) {
         if (strpos($args['before_widget'], 'class') === false) {
             $args['before_widget'] = str_replace('>', 'class="' . esc_attr($css_classes) . '"', $args['before_widget']);
         } else {
             $args['before_widget'] = str_replace('class="', 'class="' . esc_attr($css_classes) . ' ', $args['before_widget']);
         }
     }
     // Output
     echo $args['before_widget'];
     // Before widget template
     // Section template
     get_template_part('section-templates/section', 'popular-posts');
     // Get section template
     echo $args['after_widget'];
     // After widget template
 }
 /**
  * @covers WPSEO_Sitemaps::canonical
  */
 public function test_canonical()
 {
     $url = site_url();
     $this->assertNotEmpty(self::$class_instance->canonical($url));
     set_query_var('sitemap', 'sitemap_value');
     $this->assertFalse(self::$class_instance->canonical($url));
     set_query_var('xsl', 'xsl_value');
     $this->assertFalse(self::$class_instance->canonical($url));
 }
Exemple #16
0
function usp_addSubmittedStatusClause($wp_query)
{
    global $pagenow, $usp_post_meta_IsSubmission;
    if (is_admin() && $pagenow == 'edit.php' && $_GET['user_submitted'] == '1') {
        set_query_var('meta_key', $usp_post_meta_IsSubmission);
        set_query_var('meta_value', 1);
        set_query_var('post_status', 'pending');
    }
}
Exemple #17
0
function theme_exclude_category_feed()
{
    $exclude_cats = theme_get_option('blog', 'exclude_categorys');
    foreach ($exclude_cats as $key => $cat) {
        $exclude_cats[$key] = -$cat;
    }
    if (is_feed()) {
        set_query_var("cat", implode(",", $exclude_cats));
    }
}
 /**
  * Set query variable in the WP_Query class.
  *
  * Wrapper method for the WordPress core `set_query_var()` function. This is a work around for theme's and plugins
  * which break the WordPress global $wp_query var by unsetting it or overwriting it which break the method call
  * that `set_query_var()` uses to set the query variable.
  *
  * @access public
  * @since  8.5.14
  *
  * @global WP_Query $wp_query Global WP_Query instance.
  *
  * @param string $var   Query variable key.
  * @param mixed  $value Query variable value.
  */
 public static function setVar($var, $value)
 {
     global $wp_query;
     if (is_a($wp_query, 'WP_Query') && is_callable(array($wp_query, 'get'))) {
         set_query_var($var, $value);
     } else {
         $GLOBALS['wp_query']->query_vars[$var] = $value;
         $GLOBALS['wp_the_query']->query_vars[$var] = $value;
     }
 }
 /**
  * @ticket 20319
  */
 public function test_page_should_default_to_1_when_no_cpage_query_var_is_found()
 {
     $p = self::factory()->post->create();
     $this->go_to(get_permalink($p));
     $cpage = get_query_var('cpage');
     set_query_var('cpage', '');
     $link = get_next_comments_link('Next', 5);
     $this->assertContains('cpage=2', $link);
     set_query_var('cpage', $cpage);
 }
 public function loadReadMore($url, $display_type, $entityId, $readmore)
 {
     load_plugin_textdomain('sociallymap', false, '../' . basename(dirname(__FILE__)));
     set_query_var('data', ['url' => $url, 'display_type' => $display_type, 'entityId' => $entityId, 'readmore' => $readmore]);
     ob_start();
     load_template($this->urlBase . 'readmore-template.php', false);
     $readmore = ob_get_contents();
     ob_end_clean();
     return $readmore;
 }
Exemple #21
0
 function add_a2z_query($query)
 {
     remove_action("posts_where", array($this, "add_a2z_query_to_post_where"), 11);
     if ($query->is_search() && $query->is_main_query()) {
         if (isset($_GET['producta2z']) && (int) $_GET['producta2z'] == 1 && strcmp(get_query_var('post_type'), 'product') == 0) {
             set_query_var('start_char', get_query_var('s'));
             add_action("posts_where", array($this, "add_a2z_query_to_post_where"), 11);
         }
     }
 }
function handle_start_page_content()
{
    $is_home = false;
    if (is_home()) {
        $is_home = true;
        set_post_by_slug('start');
    }
    // Make sure the state available in partials
    set_query_var('is_home', $is_home);
    return $is_home;
}
Exemple #23
0
 /**
  * Output function: Prints the events calendar 'grid view'
  *
  * @return void
  */
 function event_grid_view()
 {
     global $spEvents;
     set_query_var('eventDisplay', 'bydate');
     if ($spEvents->in_event_category()) {
         if ('' == locate_template(array('events/table.php'), true)) {
             load_template(dirname(__FILE__) . '/views/table.php');
         }
         return;
     }
 }
 public function test_page_should_default_to_1_when_no_cpage_query_var_is_found()
 {
     $p = self::factory()->post->create();
     $this->go_to(get_permalink($p));
     $cpage = get_query_var('cpage');
     set_query_var('cpage', '');
     $link = get_previous_comments_link('Next', 5);
     // Technically, it returns null here.
     $this->assertEquals('', $link);
     set_query_var('cpage', $cpage);
 }
function knowledge_test()
{
    $show_score = isset($_GET['test_score']);
    if ($show_score) {
        set_query_var('knowledge_test_success', get_knowledge_test_success());
        partial('knowledge-test-success');
    } else {
        set_query_var('knowledge_test', get_knowledge_test_questions());
        partial('knowledge-test');
    }
}
 /**
  * End process of getting all Serbian variants for search.
  *
  * Use old search term back to global variable.
  *
  * @since 1.0
  * @access public
  */
 public function end()
 {
     // Get old search term
     $search_term = $this->variants_object->original_term;
     // Set back old search term as one used in global var
     $_GET['s'] = $search_term;
     // Set back old search term as one used in query var
     set_query_var('s', $search_term);
     // Deregister search parser
     remove_filter('posts_search', array($this, 'parse_search'), 1, 2);
 }
Exemple #27
0
 function author_post_limit($limits)
 {
     global $wp_query;
     if (is_author()) {
         global $wp_query;
         $options = $this->get_options();
         $limits = str_replace(get_query_var('posts_per_page'), $options['author_posts'], $limits);
         set_query_var('posts_per_page', $options['author_posts']);
     }
     return $limits;
 }
Exemple #28
0
 public function zo_register_router($params)
 {
     if (!empty($params)) {
         set_query_var('zo_params', $params);
         add_action('rest_api_init', function () {
             $params = get_query_var('zo_params');
             foreach ($params as $router) {
                 register_rest_route($router['namespace'], $router['routename'], array('methods' => $router['methods'], 'callback' => $router['callback']));
             }
         });
     }
 }
Exemple #29
0
function shortcode_generic_shortcode($atts, $content = null)
{
    $output;
    $atts = shortcode_atts(array('param_default' => null), $atts, 'generic_shortcode');
    ob_start();
    // Expose the global var to generic-shortcode-tpl.php
    set_query_var('generic_shortcode_atts', $atts);
    // Load the template
    get_template_part('./partials/generic-shortcode-tpl');
    // Optionally apply filter after content
    $output = ob_get_clean();
    return $output;
}
function get_all_comments_list()
{
    global $post;
    ob_start();
    //exit(has_shortcode($post->post_content, 'list_comments'));
    # The comment functions use the query var 'cpage', so we'll ensure that's set
    $page = intval(get_query_var('cpage'));
    if (0 == $page) {
        $page = 1;
        set_query_var('cpage', $page);
    }
    # We'll do 10 comments per page...
    # Note that the 'page_comments' option in /wp-admin/options-discussion.php must be checked
    $comments_per_page = 10;
    $comments = get_comments(array('status' => 'approve', 'meta_key' => 'notify_user', 'meta_value' => get_current_user_id()));
    ?>
    <ol start="<?php 
    echo $comments_per_page * $page - $comments_per_page + 1;
    ?>
">
        <?php 
    wp_list_comments(array('style' => 'ol', 'per_page' => $comments_per_page, 'page' => $page, 'reverse_top_level' => false), $comments);
    ?>
    </ol>

    <?php 
    // Now you can either use paginate_comments_links ...
    paginate_comments_links();
    $html = ob_get_contents();
    ob_end_clean();
    return $html;
}