abstracts
2 years ago
admin
2 years ago
elementor
4 years ago
export
3 years ago
fields
2 years ago
interfaces
8 years ago
libraries
2 years ago
log-handlers
4 years ago
shortcodes
2 years ago
stats
3 years ago
templates
5 years ago
class-everest-forms.php
2 years ago
class-evf-ajax.php
2 years ago
class-evf-autoloader.php
7 years ago
class-evf-background-updater.php
7 years ago
class-evf-cache-helper.php
6 years ago
class-evf-cron.php
3 years ago
class-evf-deprecated-action-hooks.php
6 years ago
class-evf-deprecated-filter-hooks.php
5 years ago
class-evf-emails.php
2 years ago
class-evf-fields.php
2 years ago
class-evf-form-block.php
4 years ago
class-evf-form-handler.php
3 years ago
class-evf-form-task.php
2 years ago
class-evf-forms-features.php
2 years ago
class-evf-frontend-scripts.php
2 years ago
class-evf-install.php
2 years ago
class-evf-integrations.php
7 years ago
class-evf-log-levels.php
8 years ago
class-evf-logger.php
5 years ago
class-evf-post-types.php
5 years ago
class-evf-privacy.php
6 years ago
class-evf-session-handler.php
7 years ago
class-evf-shortcodes.php
4 years ago
class-evf-smart-tags.php
2 years ago
class-evf-template-loader.php
2 years ago
class-evf-validation.php
6 years ago
evf-conditional-functions.php
6 years ago
evf-core-functions.php
2 years ago
evf-deprecated-functions.php
6 years ago
evf-entry-functions.php
3 years ago
evf-formatting-functions.php
4 years ago
evf-notice-functions.php
4 years ago
evf-template-functions.php
4 years ago
evf-template-hooks.php
7 years ago
evf-update-functions.php
5 years ago
class-evf-post-types.php
139 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Post Types |
| 4 | * |
| 5 | * Registers post types and taxonomies. |
| 6 | * |
| 7 | * @package EverestForms\Classes |
| 8 | * @version 1.0.0 |
| 9 | */ |
| 10 | |
| 11 | defined( 'ABSPATH' ) || exit; |
| 12 | |
| 13 | /** |
| 14 | * Post types Class. |
| 15 | */ |
| 16 | class EVF_Post_Types { |
| 17 | |
| 18 | /** |
| 19 | * Hook in methods. |
| 20 | */ |
| 21 | public static function init() { |
| 22 | add_action( 'init', array( __CLASS__, 'register_post_types' ), 5 ); |
| 23 | add_action( 'admin_bar_menu', array( __CLASS__, 'admin_bar_menus' ), 100 ); |
| 24 | add_action( 'everest_forms_after_register_post_type', array( __CLASS__, 'maybe_flush_rewrite_rules' ) ); |
| 25 | add_action( 'everest_forms_flush_rewrite_rules', array( __CLASS__, 'flush_rewrite_rules' ) ); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Register core post types. |
| 30 | */ |
| 31 | public static function register_post_types() { |
| 32 | if ( ! is_blog_installed() || post_type_exists( 'everest_form' ) ) { |
| 33 | return; |
| 34 | } |
| 35 | |
| 36 | do_action( 'everest_forms_register_post_type' ); |
| 37 | |
| 38 | register_post_type( |
| 39 | 'everest_form', |
| 40 | apply_filters( |
| 41 | 'everest_forms_register_post_type_product', |
| 42 | array( |
| 43 | 'labels' => array( |
| 44 | 'name' => __( 'Everest Forms', 'everest-forms' ), |
| 45 | 'singular_name' => __( 'Form', 'everest-forms' ), |
| 46 | 'all_items' => __( 'All Forms', 'everest-forms' ), |
| 47 | 'menu_name' => _x( 'Forms', 'Admin menu name', 'everest-forms' ), |
| 48 | 'add_new' => __( 'Add New', 'everest-forms' ), |
| 49 | 'add_new_item' => __( 'Add new form', 'everest-forms' ), |
| 50 | 'edit' => __( 'Edit', 'everest-forms' ), |
| 51 | 'edit_item' => __( 'Edit form', 'everest-forms' ), |
| 52 | 'new_item' => __( 'New form', 'everest-forms' ), |
| 53 | 'view_item' => __( 'View form', 'everest-forms' ), |
| 54 | 'search_items' => __( 'Search forms', 'everest-forms' ), |
| 55 | 'not_found' => __( 'No forms found', 'everest-forms' ), |
| 56 | 'not_found_in_trash' => __( 'No forms found in trash', 'everest-forms' ), |
| 57 | 'parent' => __( 'Parent forms', 'everest-forms' ), |
| 58 | 'featured_image' => __( 'Form image', 'everest-forms' ), |
| 59 | 'set_featured_image' => __( 'Set form image', 'everest-forms' ), |
| 60 | 'remove_featured_image' => __( 'Remove form image', 'everest-forms' ), |
| 61 | 'use_featured_image' => __( 'Use as form image', 'everest-forms' ), |
| 62 | 'insert_into_item' => __( 'Insert into form', 'everest-forms' ), |
| 63 | 'uploaded_to_this_item' => __( 'Uploaded to this form', 'everest-forms' ), |
| 64 | 'filter_items_list' => __( 'Filter forms', 'everest-forms' ), |
| 65 | 'items_list_navigation' => __( 'Forms navigation', 'everest-forms' ), |
| 66 | 'items_list' => __( 'Forms list', 'everest-forms' ), |
| 67 | ), |
| 68 | 'public' => false, |
| 69 | 'show_ui' => true, |
| 70 | 'description' => __( 'This is where you can add new forms.', 'everest-forms' ), |
| 71 | 'capability_type' => 'post', |
| 72 | 'publicly_queryable' => false, |
| 73 | 'exclude_from_search' => true, |
| 74 | 'show_in_rest' => true, |
| 75 | 'show_in_menu' => false, |
| 76 | 'hierarchical' => false, |
| 77 | 'rewrite' => false, |
| 78 | 'query_var' => false, |
| 79 | 'supports' => false, |
| 80 | 'show_in_nav_menus' => false, |
| 81 | 'show_in_admin_bar' => false, |
| 82 | ) |
| 83 | ) |
| 84 | ); |
| 85 | |
| 86 | do_action( 'everest_forms_after_register_post_type' ); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Add "Everest Forms" link in admin bar main menu. |
| 91 | * |
| 92 | * @since 1.2.0 |
| 93 | * @param WP_Admin_Bar $wp_admin_bar Admin bar instance. |
| 94 | */ |
| 95 | public static function admin_bar_menus( $wp_admin_bar ) { |
| 96 | if ( ! is_admin_bar_showing() || ! current_user_can( 'manage_everest_forms' ) ) { |
| 97 | return; |
| 98 | } |
| 99 | |
| 100 | // Show only when the user is a member of this site, or they're a super admin. |
| 101 | if ( ! is_user_member_of_blog() && ! is_super_admin() ) { |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | // Add an option to create new form. |
| 106 | if ( apply_filters( 'everest_forms_show_admin_bar_menus', true ) ) { |
| 107 | $wp_admin_bar->add_node( |
| 108 | array( |
| 109 | 'parent' => 'new-content', |
| 110 | 'id' => 'everest-forms', |
| 111 | 'title' => __( 'Everest Forms', 'everest-forms' ), |
| 112 | 'href' => admin_url( 'admin.php?page=evf-builder&create-form=1' ), |
| 113 | ) |
| 114 | ); |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | /** |
| 119 | * Flush rules if the event is queued. |
| 120 | * |
| 121 | * @since 1.2.0 |
| 122 | */ |
| 123 | public static function maybe_flush_rewrite_rules() { |
| 124 | if ( 'yes' === get_option( 'everest_forms_queue_flush_rewrite_rules' ) ) { |
| 125 | update_option( 'everest_forms_queue_flush_rewrite_rules', 'no' ); |
| 126 | self::flush_rewrite_rules(); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Flush rewrite rules. |
| 132 | */ |
| 133 | public static function flush_rewrite_rules() { |
| 134 | flush_rewrite_rules(); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | EVF_Post_Types::init(); |
| 139 |