Plugin Directory

Changeset 2044909


Ignore:
Timestamp:
03/06/2019 12:37:08 AM (7 years ago)
Author:
warriorrocker
Message:

Add version 1.0.1

Location:
xo-for-angular
Files:
7 edited
13 copied

Legend:

Unmodified
Added
Removed
  • xo-for-angular/tags/1.0.1/Includes/Api/Abstract/Objects/Menu.class.php

    r2042983 r2044909  
    33/**
    44 * An abstract class that extends post and used to construct a fully formed menu object.
    5  * 
     5 *
    66 * @since 1.0.0
    77 */
     
    1010    /**
    1111     * Additional css classes that may be used in the front-end.
    12      * 
     12     *
    1313     * @since 1.0.0
    14      * 
     14     *
    1515     * @var string
    1616     */
     
    1818
    1919    /**
     20     * Target for the anchor link.
     21     *
     22     * @since 1.0.1
     23     *
     24     * @var string
     25     */
     26    public $target;
     27
     28    /**
    2029     * Generate a fully formed menu object.
    21      * 
     30     *
    2231     * @since 1.0.0
    23      * 
     32     *
    2433     * @param WP_Post $menu The base menu object.
    2534     * @param bool $terms Optionally include terms in menu object.
     
    3544        $this->classes = $menu->classes;
    3645        $this->parent = $menu->menu_item_parent;
     46        $this->target = $menu->target;
    3747
    3848        // Set the relative url of the menu
    39         $this->url = wp_make_link_relative($menu->url);
     49        if ($this->target == '_blank') {
     50            $this->url = $menu->url;
     51        } else {
     52            $this->url = wp_make_link_relative($menu->url);
     53        }
    4054    }
    4155}
  • xo-for-angular/tags/1.0.1/Includes/Api/Controllers/PostsController.class.php

    r2042983 r2044909  
    108108            : (($search) ? get_post_types(array('public' => true)) : 'post'));
    109109        $curPage = ((!empty($params['currentPage'])) ? $params['currentPage'] : 1);
    110         $perPage = ((!empty($params['postsPerPage'])) ? intval($params['postsPerPage']) : -1);
     110        $perPage = intval(((!empty($params['postsPerPage']))
     111            ? $params['postsPerPage']
     112            : $this->Xo->Services->Options->GetOption('posts_per_page')));
    111113        $offset = (($perPage) ? (($curPage - 1) * $perPage) : 0);
    112114        $orderBy = ((!empty($params['orderby'])) ? $params['orderby'] : '');
    113115
    114         // Construct base arguments for get posts
     116        // Construct base arguments for get posts$default_posts_per_page = get_option( 'posts_per_page' );
    115117        $baseargs = array(
    116118            'post_status' => 'publish',
     
    146148
    147149        // Get posts from search
    148         if (($search) && ($keywords = explode(' ', trim($search))) && (count($keywords)))
    149             for ($i = (count($keywords) - 1); $i >= 0; $i--)
    150                 $postids = array_merge($postids, get_posts(array_merge($baseargs, array(
    151                     's' => $keywords[$i],
    152                     'post__not_in' => array_merge($excludeids, $postids)
    153                 ))));
    154 
    155         // Check if posts should be ordered by weight
    156         if ($orderBy == 'weight') {
    157             // Get all posts using the base args and reset fields to return full wordpress post object
    158             $posts = get_posts(array_merge($baseargs, array(
    159                 'fields' => ''
    160             )));
    161 
    162             // Iterate through posts in the collection
    163             $weighted = array();
    164             foreach ($posts as $post)
    165                 // Set a new weighted value using menu order plus some randomness
    166                 $weighted[$post->ID] = ((min($post->menu_order, 10) / 10) + (mt_rand(0, 32767) / 32767));
    167 
    168             // Sort the posts by the new weighted value
    169             arsort($weighted);
    170 
    171             // Add the new weighted post ids to collection
    172             $postids = array_merge($postids, array_keys($weighted));
     150        if ($search) {
     151            $keywords = explode(' ', trim($search));
     152
     153            if (count($keywords)) {
     154                for ($i = (count($keywords) - 1); $i >= 0; $i--) {
     155                    $postids = array_merge($postids, get_posts(array_merge($baseargs, array(
     156                        's' => $keywords[$i],
     157                        'post__not_in' => array_merge($excludeids, $postids)
     158                    ))));
     159                }
     160            }
     161
     162        // Otherwise get all posts for the current parameters
    173163        } else {
    174164            $postids = array_merge($postids, get_posts(array_merge($baseargs, array(
     
    176166            ))));
    177167        }
     168
     169        // Return an error if no posts were found
     170        if (empty($postids))
     171            return new XoApiAbstractPostsFilterResponse(false, __('Unable to locate posts.', 'xo'));
    178172
    179173        // Get the wordpress post objects for the collected post ids
  • xo-for-angular/tags/1.0.1/readme.txt

    r2043256 r2044909  
    3434== Changelog ==
    3535
     36= 1.0.1 =
     37* Added link target to menu item output
     38* Fix for posts filter api returning results when there is no match
     39
    3640= 1.0.0 =
    3741* Xo for Angular initial release.
  • xo-for-angular/tags/1.0.1/xo-angular.php

    r2042983 r2044909  
    44Plugin URI: https://angularxo.io
    55Description: Angular theme development in WordPress with templates and a powerful API.
    6 Version: 1.0.0
     6Version: 1.0.1
    77Author: Travis Brown
    88Author URI: http://www.xodustech.com
  • xo-for-angular/trunk/Includes/Api/Abstract/Objects/Menu.class.php

    r2042983 r2044909  
    33/**
    44 * An abstract class that extends post and used to construct a fully formed menu object.
    5  * 
     5 *
    66 * @since 1.0.0
    77 */
     
    1010    /**
    1111     * Additional css classes that may be used in the front-end.
    12      * 
     12     *
    1313     * @since 1.0.0
    14      * 
     14     *
    1515     * @var string
    1616     */
     
    1818
    1919    /**
     20     * Target for the anchor link.
     21     *
     22     * @since 1.0.1
     23     *
     24     * @var string
     25     */
     26    public $target;
     27
     28    /**
    2029     * Generate a fully formed menu object.
    21      * 
     30     *
    2231     * @since 1.0.0
    23      * 
     32     *
    2433     * @param WP_Post $menu The base menu object.
    2534     * @param bool $terms Optionally include terms in menu object.
     
    3544        $this->classes = $menu->classes;
    3645        $this->parent = $menu->menu_item_parent;
     46        $this->target = $menu->target;
    3747
    3848        // Set the relative url of the menu
    39         $this->url = wp_make_link_relative($menu->url);
     49        if ($this->target == '_blank') {
     50            $this->url = $menu->url;
     51        } else {
     52            $this->url = wp_make_link_relative($menu->url);
     53        }
    4054    }
    4155}
  • xo-for-angular/trunk/Includes/Api/Controllers/PostsController.class.php

    r2042983 r2044909  
    108108            : (($search) ? get_post_types(array('public' => true)) : 'post'));
    109109        $curPage = ((!empty($params['currentPage'])) ? $params['currentPage'] : 1);
    110         $perPage = ((!empty($params['postsPerPage'])) ? intval($params['postsPerPage']) : -1);
     110        $perPage = intval(((!empty($params['postsPerPage']))
     111            ? $params['postsPerPage']
     112            : $this->Xo->Services->Options->GetOption('posts_per_page')));
    111113        $offset = (($perPage) ? (($curPage - 1) * $perPage) : 0);
    112114        $orderBy = ((!empty($params['orderby'])) ? $params['orderby'] : '');
    113115
    114         // Construct base arguments for get posts
     116        // Construct base arguments for get posts$default_posts_per_page = get_option( 'posts_per_page' );
    115117        $baseargs = array(
    116118            'post_status' => 'publish',
     
    146148
    147149        // Get posts from search
    148         if (($search) && ($keywords = explode(' ', trim($search))) && (count($keywords)))
    149             for ($i = (count($keywords) - 1); $i >= 0; $i--)
    150                 $postids = array_merge($postids, get_posts(array_merge($baseargs, array(
    151                     's' => $keywords[$i],
    152                     'post__not_in' => array_merge($excludeids, $postids)
    153                 ))));
    154 
    155         // Check if posts should be ordered by weight
    156         if ($orderBy == 'weight') {
    157             // Get all posts using the base args and reset fields to return full wordpress post object
    158             $posts = get_posts(array_merge($baseargs, array(
    159                 'fields' => ''
    160             )));
    161 
    162             // Iterate through posts in the collection
    163             $weighted = array();
    164             foreach ($posts as $post)
    165                 // Set a new weighted value using menu order plus some randomness
    166                 $weighted[$post->ID] = ((min($post->menu_order, 10) / 10) + (mt_rand(0, 32767) / 32767));
    167 
    168             // Sort the posts by the new weighted value
    169             arsort($weighted);
    170 
    171             // Add the new weighted post ids to collection
    172             $postids = array_merge($postids, array_keys($weighted));
     150        if ($search) {
     151            $keywords = explode(' ', trim($search));
     152
     153            if (count($keywords)) {
     154                for ($i = (count($keywords) - 1); $i >= 0; $i--) {
     155                    $postids = array_merge($postids, get_posts(array_merge($baseargs, array(
     156                        's' => $keywords[$i],
     157                        'post__not_in' => array_merge($excludeids, $postids)
     158                    ))));
     159                }
     160            }
     161
     162        // Otherwise get all posts for the current parameters
    173163        } else {
    174164            $postids = array_merge($postids, get_posts(array_merge($baseargs, array(
     
    176166            ))));
    177167        }
     168
     169        // Return an error if no posts were found
     170        if (empty($postids))
     171            return new XoApiAbstractPostsFilterResponse(false, __('Unable to locate posts.', 'xo'));
    178172
    179173        // Get the wordpress post objects for the collected post ids
  • xo-for-angular/trunk/readme.txt

    r2043256 r2044909  
    44Requires at least: 4.9
    55Tested up to: 5.0.3
    6 Stable tag: 1.0.0
     6Stable tag: 1.0.1
    77Requires PHP: 7.0.0
    88License: GPLv2 or later
     
    3434== Changelog ==
    3535
     36= 1.0.1 =
     37* Added link target to menu item output
     38* Fix for posts filter api returning results when there is no match
     39
    3640= 1.0.0 =
    3741* Xo for Angular initial release.
  • xo-for-angular/trunk/xo-angular.php

    r2042983 r2044909  
    44Plugin URI: https://angularxo.io
    55Description: Angular theme development in WordPress with templates and a powerful API.
    6 Version: 1.0.0
     6Version: 1.0.1
    77Author: Travis Brown
    88Author URI: http://www.xodustech.com
Note: See TracChangeset for help on using the changeset viewer.