name = App::s()->getPrefix( '_post_types_checkbox' ); $this->label = __( 'Post Types', 'tmc-acfptf' ); $this->category = 'choice'; $this->defaults = array( 'show_only_custom' => false, 'show_only_public' => true, 'allow_multiple' => false, 'whitelist' => '', 'blacklist' => '' ); // ---------------------------------------- // Parent constructor // ---------------------------------------- parent::__construct(); } /** * Create extra settings for your field. These are visible when editing a field. * * @param array $field */ public function render_field_settings( $field ) { // TODO } /** * Create the HTML interface for your field * * @param array $field */ public function render_field( $field ) { // echo App::s()->utility->getFormattedVarExport( $field ); // ---------------------------------------- // Prepare whitelist/blacklist // ---------------------------------------- $whitelistAsArray = array_filter( preg_split( "/[\s,]+/", $field['whitelist'] ) ); $blacklistAsArray = array_filter( preg_split( "/[\s,]+/", $field['blacklist'] ) ); // ---------------------------------------- // Prepare list of post types // ---------------------------------------- $argsForCustom = array( 'public' => (bool) $field['show_only_public'], '_builtin' => false ); $argsForBuiltIn = array( 'public' => (bool) $field['show_only_public'], '_builtin' => true ); $customPostTypes = App::i()->utility->getPostTypesNames( $argsForCustom ); $builtInPostTypes = App::i()->utility->getPostTypesNames( $argsForBuiltIn ); if( $field['show_only_custom'] ){ $allPostTypes = $customPostTypes; // All post types? More like: only custom post types!!! } else { $allPostTypes = array_merge( $builtInPostTypes, $customPostTypes ); $allPostTypes = array_unique( $allPostTypes ); } // ---------------------------------------- // Render checkboxes/radio // ---------------------------------------- $inputType = $field['allow_multiple'] ? 'checkbox' : 'radio'; // Multiple or single select? printf( '', $field['name'] ); printf( '