admin
10 months ago
core
10 months ago
class-activator.php
10 months ago
class-assets.php
11 months ago
class-builder-page.php
1 year ago
class-deactivator.php
3 years ago
class-debug-info.php
2 years ago
class-feed-ajax.php
1 year ago
class-feed-block.php
1 year ago
class-feed-deserializer.php
11 months ago
class-feed-old.php
4 years ago
class-feed-page.php
11 months ago
class-feed-serializer.php
2 years ago
class-feed-shortcode.php
2 years ago
class-feed-widget.php
4 years ago
class-plugin-overview-ajax.php
1 year ago
class-plugin-overview.php
11 months ago
class-plugin-settings.php
10 months ago
class-plugin-support.php
1 year ago
class-plugin.php
11 months ago
class-post-types.php
3 years ago
class-reviews-cron.php
1 year ago
class-settings-save.php
1 year ago
class-view.php
10 months ago
index.php
4 years ago
page-setting-advance.php
1 year ago
page-setting-fig.php
1 year ago
page-setting-support.php
4 years ago
class-post-types.php
94 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WP_Rplg_Google_Reviews\Includes; |
| 4 | |
| 5 | class Post_Types { |
| 6 | |
| 7 | const FEED_POST_TYPE = 'grw_feed'; |
| 8 | |
| 9 | public function register() { |
| 10 | add_action('init', array($this, 'register_post_types')); |
| 11 | |
| 12 | add_action('trash_' . self::FEED_POST_TYPE, array($this, 'trash'), 10, 2); |
| 13 | add_action('publish_' . self::FEED_POST_TYPE, array($this, 'publish'), 10, 2); |
| 14 | } |
| 15 | |
| 16 | public function register_post_types() { |
| 17 | $this->register_feed_post_type(); |
| 18 | } |
| 19 | |
| 20 | public function register_feed_post_type() { |
| 21 | $labels = array( |
| 22 | 'name' => _x('Reviews widgets', 'Post Type General Name', 'widget-google-reviews'), |
| 23 | 'singular_name' => _x('Reviews widget', 'Post Type Singular Name', 'widget-google-reviews'), |
| 24 | 'menu_name' => __('Reviews widgets', 'widget-google-reviews'), |
| 25 | 'name_admin_bar' => __('Reviews widget', 'widget-google-reviews'), |
| 26 | 'archives' => __('Reviews Feed Archives', 'widget-google-reviews'), |
| 27 | 'attributes' => __('Reviews Feed Attributes', 'widget-google-reviews'), |
| 28 | 'parent_item_colon' => __('Parent Reviews Feed:', 'widget-google-reviews'), |
| 29 | 'all_items' => __('Widgets', 'widget-google-reviews'), |
| 30 | 'add_new_item' => __('Add New Reviews Feed', 'widget-google-reviews'), |
| 31 | 'add_new' => __('Add Reviews Feed', 'widget-google-reviews'), |
| 32 | 'new_item' => __('New Reviews Feed', 'widget-google-reviews'), |
| 33 | 'edit_item' => __('Edit Reviews Feed', 'widget-google-reviews'), |
| 34 | 'update_item' => __('Update Reviews Feed', 'widget-google-reviews'), |
| 35 | 'view_item' => __('View Reviews Feed', 'widget-google-reviews'), |
| 36 | 'view_items' => __('View Reviews Feeds', 'widget-google-reviews'), |
| 37 | 'search_items' => __('Search Reviews Widgets', 'widget-google-reviews'), |
| 38 | 'not_found' => __('Not found', 'widget-google-reviews'), |
| 39 | 'not_found_in_trash' => __('Not found in Trash', 'widget-google-reviews'), |
| 40 | 'featured_image' => __('Featured Image', 'widget-google-reviews'), |
| 41 | 'set_featured_image' => __('Set featured image', 'widget-google-reviews'), |
| 42 | 'remove_featured_image' => __('Remove featured image', 'widget-google-reviews'), |
| 43 | 'use_featured_image' => __('Use as featured image', 'widget-google-reviews'), |
| 44 | 'insert_into_item' => __('Insert into item', 'widget-google-reviews'), |
| 45 | 'uploaded_to_this_item' => __('Uploaded to this item', 'widget-google-reviews'), |
| 46 | 'items_list' => __('Reviews Feeds list', 'widget-google-reviews'), |
| 47 | 'items_list_navigation' => __('Reviews Feeds list navigation', 'widget-google-reviews'), |
| 48 | 'filter_items_list' => __('Filter items list', 'widget-google-reviews'), |
| 49 | ); |
| 50 | |
| 51 | $args = array( |
| 52 | 'label' => __('Reviews Feed', 'widget-google-reviews'), |
| 53 | 'labels' => $labels, |
| 54 | 'supports' => array('title'), |
| 55 | 'taxonomies' => array(), |
| 56 | 'hierarchical' => false, |
| 57 | 'public' => false, |
| 58 | 'show_in_rest' => false, |
| 59 | 'show_ui' => true, |
| 60 | 'show_in_menu' => 'grw', |
| 61 | 'show_in_admin_bar' => false, |
| 62 | 'show_in_nav_menus' => false, |
| 63 | 'can_export' => true, |
| 64 | 'has_archive' => false, |
| 65 | 'exclude_from_search' => true, |
| 66 | 'publicly_queryable' => false, |
| 67 | 'capabilities' => array('create_posts' => 'do_not_allow'), |
| 68 | 'map_meta_cap' => true, |
| 69 | ); |
| 70 | |
| 71 | register_post_type(self::FEED_POST_TYPE, $args); |
| 72 | } |
| 73 | |
| 74 | public function trash($ID) { |
| 75 | $feed_ids = get_option('grw_feed_ids'); |
| 76 | if (!empty($feed_ids)) { |
| 77 | $ids = explode(",", $feed_ids); |
| 78 | if (in_array($ID, $ids)) { |
| 79 | $ids = array_diff($ids, [$ID]); |
| 80 | update_option('grw_feed_ids', implode(",", $ids)); |
| 81 | } |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | public function publish($ID) { |
| 86 | $feed_ids = get_option('grw_feed_ids'); |
| 87 | $ids = empty($feed_ids) ? array($ID) : explode(",", $feed_ids); |
| 88 | if (!in_array($ID, $ids)) { |
| 89 | array_push($ids, $ID); |
| 90 | } |
| 91 | update_option('grw_feed_ids', implode(",", $ids)); |
| 92 | } |
| 93 | } |
| 94 |