| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FirePlugins Framework |
| 4 |
* @version 1.1.146 |
| 5 |
* |
| 6 |
* @author FirePlugins <[email protected]> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace FPFramework\Helpers; |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) |
| 15 |
{ |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
class PagesHelper |
| 20 |
{ |
| 21 |
/** |
| 22 |
* Posts Base Helper |
| 23 |
* |
| 24 |
* @var PostsBaseHelper |
| 25 |
*/ |
| 26 |
private $helper; |
| 27 |
|
| 28 |
public function __construct($helper = null) |
| 29 |
{ |
| 30 |
if (!$helper) |
| 31 |
{ |
| 32 |
$helper = new PostsBaseHelper(); |
| 33 |
} |
| 34 |
|
| 35 |
$this->helper = $helper; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Parses given data to a key,value array |
| 40 |
* |
| 41 |
* @param array $items |
| 42 |
* |
| 43 |
* @return array |
| 44 |
*/ |
| 45 |
public static function parseData($items) |
| 46 |
{ |
| 47 |
return PostsBaseHelper::parseData($items); |
| 48 |
} |
| 49 |
|
| 50 |
/** |
| 51 |
* Returns items based on offset and limit |
| 52 |
* |
| 53 |
* @param integer $offset |
| 54 |
* @param integer $limit |
| 55 |
* @param String $post_type |
| 56 |
* |
| 57 |
* @return array |
| 58 |
*/ |
| 59 |
public function getItems($offset = 0, $limit = SearchDropdownHelper::SELECTION_ITEMS, $post_type = 'page') |
| 60 |
{ |
| 61 |
return $this->helper->getItems($offset, $limit, $post_type); |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Gets Pages from the Selected Items |
| 66 |
* |
| 67 |
* @param array $items |
| 68 |
* @param String $post_type |
| 69 |
* |
| 70 |
* @return array |
| 71 |
*/ |
| 72 |
public function getSelectedItems($items, $post_type = 'page') |
| 73 |
{ |
| 74 |
$post_type = !is_string($post_type) ? 'page' : $post_type; |
| 75 |
|
| 76 |
return $this->helper->getSelectedItems($items, $post_type); |
| 77 |
} |
| 78 |
|
| 79 |
/** |
| 80 |
* Searches the pages and returns an array of items |
| 81 |
* |
| 82 |
* @param String $name |
| 83 |
* @param array $no_ids List of already added items |
| 84 |
* @param String $post_type |
| 85 |
* |
| 86 |
* @return array |
| 87 |
*/ |
| 88 |
public function getSearchItems($name, $no_ids = null, $post_type = 'page') |
| 89 |
{ |
| 90 |
return $this->helper->getSearchItems($name, $no_ids, $post_type); |
| 91 |
} |
| 92 |
} |