| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FirePlugins Framework |
| 4 | - * @version 1.0.16 | |
| 4 | + * @version 1.2.6 | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2021 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FPFramework\Libs; |
| @@ -58,8 +58,18 @@ | ||
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | + * Set whether the CPT can run. | |
| 63 | + * | |
| 64 | + * @return bool | |
| 65 | + */ | |
| 66 | + protected function canRun() | |
| 67 | + { | |
| 68 | + return true; | |
| 69 | + } | |
| 70 | + | |
| 71 | + /** | |
| 62 | 72 | * Registers the Custom Post Type |
| 63 | 73 | * |
| 64 | 74 | * @return void |
| 65 | 75 | */ |
| @@ -64,17 +74,22 @@ | ||
| 64 | 74 | * @return void |
| 65 | 75 | */ |
| 66 | 76 | public function register() |
| 67 | 77 | { |
| 78 | + if (!$this->canRun()) | |
| 79 | + { | |
| 80 | + return; | |
| 81 | + } | |
| 82 | + | |
| 68 | 83 | $singular = $this->args->get('singular'); |
| 69 | 84 | $plural = $this->args->get('plural'); |
| 70 | 85 | |
| 71 | 86 | // Default labels. |
| 72 | - $labels = array( | |
| 73 | - 'name' => sprintf( fpframework()->_('FPF_%S'), $plural ), | |
| 74 | - 'singular_name' => sprintf( fpframework()->_('FPF_%S'), $singular ), | |
| 75 | - 'menu_name' => sprintf( fpframework()->_('FPF_%S'), $plural ), | |
| 76 | - 'all_items' => sprintf( fpframework()->_('FPF_%S'), $plural ), | |
| 87 | + $labels = [ | |
| 88 | + 'name' => $plural, | |
| 89 | + 'singular_name' => $singular, | |
| 90 | + 'menu_name' => $plural, | |
| 91 | + 'all_items' => $plural, | |
| 77 | 92 | 'add_new' => fpframework()->_('FPF_ADD_NEW'), |
| 78 | 93 | 'add_new_item' => sprintf( fpframework()->_('FPF_ADD_NEW_%S'), $singular ), |
| 79 | 94 | 'edit_item' => sprintf( fpframework()->_('FPF_EDIT_%S'), $singular ), |
| 80 | 95 | 'new_item' => sprintf( fpframework()->_('FPF_NEW_%S'), $singular ), |
| @@ -81,10 +96,10 @@ | ||
| 81 | 96 | 'view_item' => sprintf( fpframework()->_('FPF_VIEW_%S'), $singular ), |
| 82 | 97 | 'search_items' => sprintf( fpframework()->_('FPF_SEARCH_%S'), $plural ), |
| 83 | 98 | 'not_found' => sprintf( fpframework()->_('FPF_NO_%S_FOUND'), $plural ), |
| 84 | 99 | 'not_found_in_trash' => sprintf( fpframework()->_('FPF_NO_%S_FOUND_IN_TRASH'), $plural ), |
| 85 | - 'parent_item_colon' => sprintf( fpframework()->_('FPF_PARENT_%S'), $singular ) | |
| 86 | - ); | |
| 100 | + 'parent_item_colon' => sprintf( fpframework()->_('FPF_PARENT_%S:'), $singular ) | |
| 101 | + ]; | |
| 87 | 102 | |
| 88 | 103 | $payload = [ |
| 89 | 104 | 'labels' => $labels |
| 90 | 105 | ]; |
| @@ -131,9 +146,9 @@ | ||
| 131 | 146 | 'label' => $singular, |
| 132 | 147 | 'labels' => $labels, |
| 133 | 148 | 'public' => true, |
| 134 | 149 | 'map_meta_cap' => true, |
| 135 | - 'hierarchical' => false, | |
| 150 | + 'hierarchical' => $this->args->get('hierarchical', false), | |
| 136 | 151 | 'rewrite' => [ |
| 137 | 152 | 'slug' => $this->args->get('slug'), |
| 138 | 153 | ] |
| 139 | 154 | ]; |
| @@ -141,9 +156,9 @@ | ||
| 141 | 156 | $payload = array_replace_recursive( $defaults, $payload ); |
| 142 | 157 | |
| 143 | 158 | // register custom post type |
| 144 | 159 | register_post_type($this->args->get('name'), $payload); |
| 145 | - | |
| 160 | + | |
| 146 | 161 | // register taxonomies |
| 147 | 162 | $this->registerTaxonomies($this->args); |
| 148 | 163 | } |
| 149 | 164 | |
| @@ -181,20 +196,20 @@ | ||
| 181 | 196 | |
| 182 | 197 | $cap_slug = $cpt_slug . '_' . $tax; |
| 183 | 198 | |
| 184 | 199 | $labels = [ |
| 185 | - 'name' => _x( $plural, 'taxonomy general name', 'fpf-framework' ), | |
| 186 | - 'singular_name' => _x( $singular, 'taxonomy singular name', 'fpf-framework' ), | |
| 187 | - 'search_items' => __( 'Search ' . $plural, 'fpf-framework' ), | |
| 188 | - 'all_items' => __( 'All ' . $plural, 'fpf-framework' ), | |
| 189 | - 'parent_item' => __( 'Parent ' . $singular, 'fpf-framework' ), | |
| 190 | - 'parent_item_colon' => __( 'Parent ' . $singular . ':', 'fpf-framework' ), | |
| 191 | - 'edit_item' => __( 'Edit ' . $singular, 'fpf-framework' ), | |
| 192 | - 'update_item' => __( 'Update ' . $singular, 'fpf-framework' ), | |
| 193 | - 'add_new_item' => __( 'Add New ' . $singular, 'fpf-framework' ), | |
| 194 | - 'new_item_name' => __( 'New ' . $singular . ' Name', 'fpf-framework' ), | |
| 195 | - 'menu_name' => __( $plural, 'fpf-framework' ), | |
| 196 | - 'choose_from_most_used' => __( 'Choose from most used ' . $tax, 'fpf-framework' ), | |
| 200 | + 'name' => $plural, | |
| 201 | + 'singular_name' => $singular, | |
| 202 | + 'search_items' => sprintf(fpframework()->_('FPF_SEARCH_%S'), $plural), | |
| 203 | + 'all_items' => sprintf(fpframework()->_('FPF_ALL_%S'), $plural), | |
| 204 | + 'parent_item' => sprintf(fpframework()->_('FPF_PARENT_%S'), $singular), | |
| 205 | + 'parent_item_colon' => sprintf(fpframework()->_('FPF_PARENT_%S:'), $singular), | |
| 206 | + 'edit_item' => sprintf(fpframework()->_('FPF_EDIT_%S'), $singular), | |
| 207 | + 'update_item' => sprintf(fpframework()->_('FPF_UPDATE_%S'), $singular), | |
| 208 | + 'add_new_item' => sprintf(fpframework()->_('FPF_ADD_NEW_%S'), $singular), | |
| 209 | + 'new_item_name' => sprintf(fpframework()->_('FPF_NEW_%S_NAME'), $singular), | |
| 210 | + 'menu_name' => $plural, | |
| 211 | + 'choose_from_most_used' => sprintf(fpframework()->_('FPF_CHOOSE_FROM_MOST_USED_%S'), $tax), | |
| 197 | 212 | ]; |
| 198 | 213 | |
| 199 | 214 | $show_admin_column = isset($data->show_admin_column) ? $data->show_admin_column : true; |
| 200 | 215 | |