initial_static_options = array ( 'has_pro_version' =>0, 'show_opts' =>true, 'show_rating_message'=>true, 'display_tabs' =>true, 'required_role' =>'install_plugins', 'default_managed' =>'network', //network, singlesite ); $this->initial_user_options = array ( 'enable_shortcodes_in_acf_fields' => false ); $this->shortcodes = [ $this->shortcode_name =>[ 'description'=>__('Output the all custom fields from groups (from "Advanced Custom Fields", "Pods" or etc.)', 'all-custom-fields-groups'), 'atts'=>[ [ 'acf_group', 'i.e: 123 or i.e: Title Of Group', __('Enter either ID of "Advanced Custom Fields" group (you can find the ID in the url of ACF group-edit page) or title of the group', 'all-custom-fields-groups') ], [ 'show_empty_fields', 'true', __('Shows/hides the fields that were empty for the post', 'all-custom-fields-groups') ], [ 'excluded_fields', 'field1,field2', __('Enter keyNames of fields which you want to exclude from output of the group fields', 'all-custom-fields-groups') ], [ 'separator', ',
', __('In case of multi-option output (like multiple checkboxes or etc...) how the values should be separated from each other. Use '.$this->newlinePhrase.' to express the new-line character.', 'all-custom-fields-groups') ], [ 'clearfix', true, __('Include newline separator <div style="clear:both;"></div> before&after the output.', 'all-custom-fields-groups') ] ] ] ]; } public function __construct_my() { $this->register_stylescript('wp', 'style', 'all-custom-fields-groups-styles', 'assets/style.css'); if ($this->opts['enable_shortcodes_in_acf_fields']) { // https://www.advancedcustomfields.com/resources/acf-format_value/ add_filter('acf/format_value/type=textarea', 'do_shortcode'); add_filter('acf/format_value/type=text', 'do_shortcode'); } } // ============================================================================================================== // // ============================================================================================================== // public function custom_fields_groups($atts, $content=false) { $args = $this->shortcode_atts($this->shortcode_name, $atts); return $this->shortcode_wrapper($args, $content=false); } // https://www.advancedcustomfields.com/resources/get_fields/ // http://www.advancedcustomfields.com/resources/get_field_objects/ public function shortcode_wrapper( $atts , $content=false) { if (!array_key_exists('acf_group', $atts)) return __('"acf_group" attribute not found', 'all-custom-fields-groups'); $acf_group = $atts['acf_group']; if (is_numeric($acf_group)) { $acf_postgroup_id = $acf_group; } else{ $post = get_page_by_title( $acf_group, OBJECT, 'acf-field-group' ); if (empty($post)) { return __('acf_group with title '.sanitize_title($acf_group).' was not found', 'all-custom-fields-groups'); } $acf_postgroup_id = $post->ID; } $excluded_fields = array_key_exists('excluded_fields', $atts) ? explode(',', $atts['excluded_fields']) : []; $fields = acf_get_fields($acf_postgroup_id); $out =''; $separator = str_replace($this->newlinePhrase, "\n", $atts['separator']); if( $fields ) { foreach( $fields as $field ) { if (in_array($field['key'], $excluded_fields)) continue; $value = get_field( $field['name'] ); if(!empty($value) || $atts['show_empty_fields'] ) { $valueContent = ''; if (!is_array($value)) { $valueContent=$value; } else { foreach($value as $key2=>$value2) { $valueContent .= $value2 . $separator; } } $out .= ' '. $field['label']. ': '. $valueContent .' '; } } } if (!empty($out)) { $out = ''.$out.'
'; $out .= ''; } return apply_filters( 'custom_fields_groups', $out, $atts ); } // =================================== Options page ================================ // public function opts_page_output() { $this->settings_page_part("start"); ?> active_tab=="Options") { //if form updated if( !empty( $_POST["_wpnonce"] ) && check_admin_referer( "nonce_" . $this->plugin_slug, "_wpnonce" ) ) { $this->opts['enable_shortcodes_in_acf_fields'] = !empty($_POST[ $this->plugin_slug ]['enable_shortcodes_in_acf_fields']); $this->opts['bs_shortcode_default'] = stripslashes( sanitize_text_field($_POST[ $this->plugin_slug ]['bs_shortcode_default']) ); $this->update_opts(); } ?>

opts['enable_shortcodes_in_acf_fields']); ?> />
'mainsubmit-button'] ); ?> plugin_slug); ?>
settings_page_part("end"); } } // End Of Class $GLOBALS[__NAMESPACE__] = new PluginClass(); } // End Of NameSpace ?>