id, $plugin_pages, true ) ) { return; } // Load minified assets if SCRIPT_DEBUG is turned off. $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; // Scripts. wp_register_script( 'wpccp-select2', WPCCP_PLUGIN_URL . 'assets/js/select2' . $suffix . '.js', [ 'jquery' ], filemtime( WPCCP_PLUGIN_DIR . 'assets/js/select2' . $suffix . '.js' ), true ); wp_enqueue_script( 'wpccp-select2' ); wp_register_script( 'wpccp-admin', WPCCP_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', [ 'jquery', 'wpccp-select2' ], filemtime( WPCCP_PLUGIN_DIR . 'assets/js/admin' . $suffix . '.js' ), true ); wp_enqueue_script( 'wpccp-admin' ); // Inline scripts. $wpccp_nonce = wp_create_nonce( 'wpccp_ajax' ); wp_add_inline_script( 'wpccp-admin', sprintf( 'const wpccpNonce=\'%s\'', $wpccp_nonce ), 'before' ); // Styles. wp_register_style( 'wpccp-select2', WPCCP_PLUGIN_URL . 'assets/css/select2' . $suffix . '.css', [], filemtime( WPCCP_PLUGIN_DIR . 'assets/css/select2' . $suffix . '.css' ) ); wp_enqueue_style( 'wpccp-select2' ); wp_register_style( 'wpccp-admin', WPCCP_PLUGIN_URL . 'assets/css/admin' . $suffix . '.css', [ 'wpccp-select2' ], filemtime( WPCCP_PLUGIN_DIR . 'assets/css/admin' . $suffix . '.css' ) ); wp_enqueue_style( 'wpccp-admin' ); } /** * Register options * * @since 2.0.0 * @access public * * @return void */ public static function register_settings() { // Register setting. register_setting( 'wpccp', 'wpccp' ); // Register section. add_settings_section( 'wpccp_exclude_settings', __( 'Disable Protection', 'wpccp' ), [ __CLASS__, 'render_exclude_section' ], 'wpccp' ); // Register section. add_settings_section( 'wpccp_pro_settings', __( 'More Settings', 'wpccp' ), [ __CLASS__, 'render_pro_section' ], 'wpccp' ); // Register fields. // Field: Exclude Pages. add_settings_field( 'protection_message', __( 'Message', 'wpccp' ), [ __CLASS__, 'render_message_field' ], 'wpccp', 'wpccp_exclude_settings' ); // Field: Exclude Pages. add_settings_field( 'exclude_pages', __( 'On Page(s)', 'wpccp' ), [ __CLASS__, 'render_pages_field' ], 'wpccp', 'wpccp_exclude_settings' ); // Field: Exclude Posts. add_settings_field( 'exclude_posts', __( 'On Post(s)', 'wpccp' ), [ __CLASS__, 'render_posts_field' ], 'wpccp', 'wpccp_exclude_settings' ); // Field: Exclude PostTypes. add_settings_field( 'exclude_post_types', __( 'On Custom PostType(s)', 'wpccp' ), [ __CLASS__, 'render_post_types_field' ], 'wpccp', 'wpccp_pro_settings' ); // Field: Exclude Categories. add_settings_field( 'exclude_categories', __( 'On Categories', 'wpccp' ), [ __CLASS__, 'render_categories_field' ], 'wpccp', 'wpccp_exclude_settings' ); // Field: Exclude Roles. add_settings_field( 'exclude_roles', __( 'For Roles', 'wpccp' ), [ __CLASS__, 'render_roles_field' ], 'wpccp', 'wpccp_pro_settings' ); // Field: Exclude Registered. add_settings_field( 'exclude_registered', __( 'For Registered User', 'wpccp' ), [ __CLASS__, 'render_registered_field' ], 'wpccp', 'wpccp_exclude_settings' ); // Field: Exclude Admin. add_settings_field( 'exclude_admin', __( 'For Admin User', 'wpccp' ), [ __CLASS__, 'render_admin_field' ], 'wpccp', 'wpccp_exclude_settings' ); // Field: Exclude Paste (Ctrl + V). add_settings_field( 'exclude_paste', __( 'On Paste', 'wpccp' ), [ __CLASS__, 'render_paste_field' ], 'wpccp', 'wpccp_exclude_settings' ); // Field: Exclude Print Screen. add_settings_field( 'exclude_print_screen', __( 'On Print Screen', 'wpccp' ), [ __CLASS__, 'render_print_screen_field' ], 'wpccp', 'wpccp_pro_settings' ); // Field: Exclude Links. add_settings_field( 'exclude_links', __( 'On Links', 'wpccp' ), [ __CLASS__, 'render_links_field' ], 'wpccp', 'wpccp_pro_settings' ); // Field: Exclude Feed. add_settings_field( 'protect_feed', __( 'On Feed', 'wpccp' ), [ __CLASS__, 'render_feed_field' ], 'wpccp', 'wpccp_pro_settings' ); } /** * Render Section: General Settings * * @return void */ public static function render_exclude_section() { esc_html_e( 'Fine tune protection by excluding content and actions based on conditions below', 'wpccp' ); } /** * Render Section: Pro Settings * * @return void */ public static function render_pro_section() { esc_html_e( 'Get fine control with more settings avilable in pro', 'wpccp' ); include_once 'views/upgrade.php'; } /** * Render Field: Protection Message */ public static function render_message_field() { $message = ! empty( self::$options['protection_message'] ) ? self::$options['protection_message'] : ''; ?>
true, '_builtin' => false, ]; $custom_post_types = get_post_types( $custom_type_args, 'names', 'and' ); // Get Saved Settings. $post_types = ! empty( self::$options['exclude_post_types'] ) ? self::$options['exclude_post_types'] : []; // Render Field. if ( empty( $custom_post_types ) ) { echo esc_html_e( 'No custom posttype(s) found', 'wpccp' ); return; } ?>
false ] ); $categories = ! empty( self::$options['exclude_categories'] ) ? self::$options['exclude_categories'] : []; ?>
>
>
>
>
>
>
$search_q, 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => 10, 'post_type' => $search_type, 'suppress_filters' => true, ]; $search_results = new \WP_Query( $search_args ); if ( $search_results->have_posts() ) { while ( $search_results->have_posts() ) { $search_results->the_post(); $title = $search_results->post->post_title; if ( mb_strlen( $title ) > 50 ) { $title = mb_substr( $search_results->post->post_title, 0, 49 ) . '...'; } $posts[] = array( $search_results->post->ID, $title ); } } echo wp_json_encode( $posts ); wp_die(); } }