├── .gitignore ├── README.md ├── README.txt ├── acf-form-shortcode.php ├── admin ├── class-acf-form-shortcode-admin.php └── index.php ├── includes ├── class-acf-form-shortcode-activator.php ├── class-acf-form-shortcode-deactivator.php ├── class-acf-form-shortcode-i18n.php ├── class-acf-form-shortcode-loader.php ├── class-acf-form-shortcode.php └── index.php ├── index.php ├── languages └── acf-form-shortcode.pot ├── public ├── class-acf-form-shortcode-public.php └── index.php └── uninstall.php /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .htaccess 3 | sitemap.xml 4 | sitemap.xml.gz 5 | wp-config.php 6 | wp-content/advanced-cache.php 7 | wp-content/backup-db/ 8 | wp-content/backups/ 9 | wp-content/blogs.dir/ 10 | wp-content/cache/ 11 | wp-content/upgrade/ 12 | wp-content/uploads/ 13 | wp-content/wp-cache-config.php 14 | wp-content/plugins/hello.php 15 | 16 | /readme.html 17 | /license.txt 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # acf-form-shortcode 2 | Creates a shortcode for implementing acf_form directly in the editor 3 | 4 | ## Usage ## 5 | Install as you would any plugin. 6 | After activation you can now use the `[show_acf_form]` shortcode. It takes *all* options that acf_form takes. To set array values just comma-separate them. To set associative array values use | to separate key=>value pairs. 7 | 8 | ## Example usage ## 9 | ``` 10 | [show_acf_form id="tavlingsansokan-form" field_groups="1496,1451" post_id="new_post" new_post="post_type|tavlingsansokningar,post_status|publish" submit_value="Skicka" updated_message="Ansökan mottagen"] 11 | ``` 12 | 13 | ## Limitations ## 14 | * The shortcode will only work in the default wysiwyg editor as of now. 15 | * `acf_form_header()` is automatically added by detecting the shortcode in the post_content so it will only work for single page/post views. To make it work on say an archive you could add the function yourself: 16 | ``` 17 | 18 | ``` 19 | 20 | ## Bugs and requests ## 21 | Open up an issue -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | === Plugin Name === 2 | Contributors: (this should be a list of wordpress.org userid's) 3 | Donate link: https://github.com/jonathan-dejong 4 | Tags: comments, spam 5 | Requires at least: 3.0.1 6 | Tested up to: 3.4 7 | Stable tag: 4.3 8 | License: GPLv2 or later 9 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 10 | 11 | Here is a short description of the plugin. This should be no more than 150 characters. No markup here. 12 | 13 | == Description == 14 | 15 | This is the long description. No limit, and you can use Markdown (as well as in the following sections). 16 | 17 | For backwards compatibility, if this section is missing, the full length of the short description will be used, and 18 | Markdown parsed. 19 | 20 | A few notes about the sections above: 21 | 22 | * "Contributors" is a comma separated list of wp.org/wp-plugins.org usernames 23 | * "Tags" is a comma separated list of tags that apply to the plugin 24 | * "Requires at least" is the lowest version that the plugin will work on 25 | * "Tested up to" is the highest version that you've *successfully used to test the plugin*. Note that it might work on 26 | higher versions... this is just the highest one you've verified. 27 | * Stable tag should indicate the Subversion "tag" of the latest stable version, or "trunk," if you use `/trunk/` for 28 | stable. 29 | 30 | Note that the `readme.txt` of the stable tag is the one that is considered the defining one for the plugin, so 31 | if the `/trunk/readme.txt` file says that the stable tag is `4.3`, then it is `/tags/4.3/readme.txt` that'll be used 32 | for displaying information about the plugin. In this situation, the only thing considered from the trunk `readme.txt` 33 | is the stable tag pointer. Thus, if you develop in trunk, you can update the trunk `readme.txt` to reflect changes in 34 | your in-development version, without having that information incorrectly disclosed about the current stable version 35 | that lacks those changes -- as long as the trunk's `readme.txt` points to the correct stable tag. 36 | 37 | If no stable tag is provided, it is assumed that trunk is stable, but you should specify "trunk" if that's where 38 | you put the stable version, in order to eliminate any doubt. 39 | 40 | == Installation == 41 | 42 | This section describes how to install the plugin and get it working. 43 | 44 | e.g. 45 | 46 | 1. Upload `acf-form-shortcode.php` to the `/wp-content/plugins/` directory 47 | 1. Activate the plugin through the 'Plugins' menu in WordPress 48 | 1. Place `` in your templates 49 | 50 | == Frequently Asked Questions == 51 | 52 | = A question that someone might have = 53 | 54 | An answer to that question. 55 | 56 | = What about foo bar? = 57 | 58 | Answer to foo bar dilemma. 59 | 60 | == Screenshots == 61 | 62 | 1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from 63 | the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets 64 | directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png` 65 | (or jpg, jpeg, gif). 66 | 2. This is the second screen shot 67 | 68 | == Changelog == 69 | 70 | = 1.0 = 71 | * A change since the previous version. 72 | * Another change. 73 | 74 | = 0.5 = 75 | * List versions from most recent at top to oldest at bottom. 76 | 77 | == Upgrade Notice == 78 | 79 | = 1.0 = 80 | Upgrade notices describe the reason a user should upgrade. No more than 300 characters. 81 | 82 | = 0.5 = 83 | This version fixes a security related bug. Upgrade immediately. 84 | 85 | == Arbitrary section == 86 | 87 | You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated 88 | plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or 89 | "installation." Arbitrary sections will be shown below the built-in sections outlined above. 90 | 91 | == A brief Markdown Example == 92 | 93 | Ordered list: 94 | 95 | 1. Some feature 96 | 1. Another feature 97 | 1. Something else about the plugin 98 | 99 | Unordered list: 100 | 101 | * something 102 | * something else 103 | * third thing 104 | 105 | Here's a link to [WordPress](http://wordpress.org/ "Your favorite software") and one to [Markdown's Syntax Documentation][markdown syntax]. 106 | Titles are optional, naturally. 107 | 108 | [markdown syntax]: http://daringfireball.net/projects/markdown/syntax 109 | "Markdown is what the parser uses to process much of the readme file" 110 | 111 | Markdown uses email style notation for blockquotes and I've been told: 112 | > Asterisks for *emphasis*. Double it up for **strong**. 113 | 114 | `` -------------------------------------------------------------------------------- /acf-form-shortcode.php: -------------------------------------------------------------------------------- 1 | run(); 73 | 74 | } 75 | run_acf_form_shortcode(); 76 | -------------------------------------------------------------------------------- /admin/class-acf-form-shortcode-admin.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Acf_Form_Shortcode_Admin { 24 | 25 | /** 26 | * The ID of this plugin. 27 | * 28 | * @since 1.0.0 29 | * @access private 30 | * @var string $plugin_name The ID of this plugin. 31 | */ 32 | private $plugin_name; 33 | 34 | /** 35 | * The version of this plugin. 36 | * 37 | * @since 1.0.0 38 | * @access private 39 | * @var string $version The current version of this plugin. 40 | */ 41 | private $version; 42 | 43 | /** 44 | * Initialize the class and set its properties. 45 | * 46 | * @since 1.0.0 47 | * @param string $plugin_name The name of this plugin. 48 | * @param string $version The version of this plugin. 49 | */ 50 | public function __construct( $plugin_name, $version ) { 51 | 52 | $this->plugin_name = $plugin_name; 53 | $this->version = $version; 54 | 55 | } 56 | 57 | 58 | /** 59 | * Our main shortcode function 60 | * Outputs the acf_form (or rather returns it) 61 | * 62 | * @since 1.0.0 63 | */ 64 | public function show_acf_form( $options ){ 65 | 66 | /** 67 | * Setup form arguments 68 | */ 69 | $options = shortcode_atts( array( 70 | 71 | /* (string) Unique identifier for the form. Defaults to 'acf-form' */ 72 | 'id' => 'acf-form', 73 | 74 | /* (int|string) The post ID to load data from and save data to. Defaults to the current post ID. 75 | Can also be set to 'new_post' to create a new post on submit */ 76 | 'post_id' => false, 77 | 78 | /* (array) An array of post data used to create a post. See wp_insert_post for available parameters. 79 | The above 'post_id' setting must contain a value of 'new_post' */ 80 | 'new_post' => false, 81 | 82 | /* (array) An array of field group IDs/keys to override the fields displayed in this form */ 83 | 'field_groups' => false, 84 | 85 | /* (array) An array of field IDs/keys to override the fields displayed in this form */ 86 | 'fields' => false, 87 | 88 | /* (boolean) Whether or not to show the post title text field. Defaults to false */ 89 | 'post_title' => false, 90 | 91 | /* (boolean) Whether or not to show the post content editor field. Defaults to false */ 92 | 'post_content' => false, 93 | 94 | /* (boolean) Whether or not to create a form element. Useful when a adding to an existing form. Defaults to true */ 95 | 'form' => true, 96 | 97 | /* (array) An array or HTML attributes for the form element */ 98 | 'form_attributes' => array(), 99 | 100 | /* (string) The URL to be redirected to after the form is submit. Defaults to the current URL with a GET parameter '?updated=true'. 101 | A special placeholder '%post_url%' will be converted to post's permalink (handy if creating a new post) */ 102 | 'return' => '?updated=true', 103 | 104 | /* (string) Extra HTML to add before the fields */ 105 | 'html_before_fields' => '', 106 | 107 | /* (string) Extra HTML to add after the fields */ 108 | 'html_after_fields' => '', 109 | 110 | /* (string) The text displayed on the submit button */ 111 | 'submit_value' => __("Update", 'acf'), 112 | 113 | /* (string) A message displayed above the form after being redirected. Can also be set to false for no message */ 114 | 'updated_message' => __("Post updated", 'acf'), 115 | 116 | /* (string) Determines where field labels are places in relation to fields. Defaults to 'top'. 117 | Choices of 'top' (Above fields) or 'left' (Beside fields) */ 118 | 'label_placement' => 'top', 119 | 120 | /* (string) Determines where field instructions are places in relation to fields. Defaults to 'label'. 121 | Choices of 'label' (Below labels) or 'field' (Below fields) */ 122 | 'instruction_placement' => 'label', 123 | 124 | /* (string) Determines element used to wrap a field. Defaults to 'div' 125 | Choices of 'div', 'tr', 'td', 'ul', 'ol', 'dl' */ 126 | 'field_el' => 'div', 127 | 128 | /* (string) Whether to use the WP uploader or a basic input for image and file fields. Defaults to 'wp' 129 | Choices of 'wp' or 'basic'. Added in v5.2.4 */ 130 | 'uploader' => 'wp', 131 | 132 | /* (boolean) Whether to include a hidden input field to capture non human form submission. Defaults to true. Added in v5.3.4 */ 133 | 'honeypot' => true 134 | 135 | ), $options, 'show_acf_form' ); 136 | 137 | 138 | /** 139 | * Reformat all arrays back to being actual arrays 140 | */ 141 | 142 | $options['field_groups'] = ( $options['field_groups'] ? explode(',', $options['field_groups']) : $options['field_groups'] ); 143 | $options['fields'] = ( $options['fields'] ? explode(',', $options['fields']) : $options['fields'] ); 144 | 145 | /** 146 | * Fix associative arrays 147 | */ 148 | 149 | $options['form_attributes'] = ( $options['form_attributes'] ? explode(',', $options['form_attributes']) : $options['form_attributes'] ); 150 | if( is_array($options['form_attributes']) ){ 151 | foreach ( $options['form_attributes'] as $key => $value ){ 152 | $pair = explode('|', $value); 153 | if( count($pair) > 1 ){ 154 | unset($options['form_attributes'][$key]); 155 | $options['form_attributes'][$pair[0]] = $pair[1]; 156 | 157 | } 158 | 159 | } 160 | 161 | } 162 | 163 | $options['new_post'] = ( $options['new_post'] ? explode(',', $options['new_post']) : $options['new_post'] ); 164 | if( is_array($options['new_post']) ){ 165 | foreach ( $options['new_post'] as $key => $value ){ 166 | $pair = explode('|', $value); 167 | if( count($pair) > 1 ){ 168 | unset($options['new_post'][$key]); 169 | $options['new_post'][$pair[0]] = $pair[1]; 170 | 171 | } 172 | 173 | } 174 | 175 | } 176 | 177 | /** 178 | * Output acf form to buffer and then return it for the shortcode 179 | */ 180 | ob_start(); 181 | acf_form($options); 182 | $form = ob_get_clean(); 183 | return $form; 184 | 185 | } 186 | 187 | } 188 | -------------------------------------------------------------------------------- /admin/index.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Acf_Form_Shortcode_Activator { 24 | 25 | /** 26 | * Short Description. (use period) 27 | * 28 | * Long Description. 29 | * 30 | * @since 1.0.0 31 | */ 32 | public static function activate() { 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /includes/class-acf-form-shortcode-deactivator.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Acf_Form_Shortcode_Deactivator { 24 | 25 | /** 26 | * Short Description. (use period) 27 | * 28 | * Long Description. 29 | * 30 | * @since 1.0.0 31 | */ 32 | public static function deactivate() { 33 | 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /includes/class-acf-form-shortcode-i18n.php: -------------------------------------------------------------------------------- 1 | 26 | */ 27 | class Acf_Form_Shortcode_i18n { 28 | 29 | 30 | /** 31 | * Load the plugin text domain for translation. 32 | * 33 | * @since 1.0.0 34 | */ 35 | public function load_plugin_textdomain() { 36 | 37 | load_plugin_textdomain( 38 | 'acf-form-shortcode', 39 | false, 40 | dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/' 41 | ); 42 | 43 | } 44 | 45 | 46 | 47 | } 48 | -------------------------------------------------------------------------------- /includes/class-acf-form-shortcode-loader.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class Acf_Form_Shortcode_Loader { 25 | 26 | /** 27 | * The array of actions registered with WordPress. 28 | * 29 | * @since 1.0.0 30 | * @access protected 31 | * @var array $actions The actions registered with WordPress to fire when the plugin loads. 32 | */ 33 | protected $actions; 34 | 35 | /** 36 | * The array of filters registered with WordPress. 37 | * 38 | * @since 1.0.0 39 | * @access protected 40 | * @var array $filters The filters registered with WordPress to fire when the plugin loads. 41 | */ 42 | protected $filters; 43 | 44 | /** 45 | * Initialize the collections used to maintain the actions and filters. 46 | * 47 | * @since 1.0.0 48 | */ 49 | public function __construct() { 50 | 51 | $this->actions = array(); 52 | $this->filters = array(); 53 | 54 | } 55 | 56 | /** 57 | * Add a new action to the collection to be registered with WordPress. 58 | * 59 | * @since 1.0.0 60 | * @param string $hook The name of the WordPress action that is being registered. 61 | * @param object $component A reference to the instance of the object on which the action is defined. 62 | * @param string $callback The name of the function definition on the $component. 63 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. 64 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1. 65 | */ 66 | public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 67 | $this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args ); 68 | } 69 | 70 | /** 71 | * Add a new filter to the collection to be registered with WordPress. 72 | * 73 | * @since 1.0.0 74 | * @param string $hook The name of the WordPress filter that is being registered. 75 | * @param object $component A reference to the instance of the object on which the filter is defined. 76 | * @param string $callback The name of the function definition on the $component. 77 | * @param int $priority Optional. he priority at which the function should be fired. Default is 10. 78 | * @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1 79 | */ 80 | public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) { 81 | $this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args ); 82 | } 83 | 84 | /** 85 | * A utility function that is used to register the actions and hooks into a single 86 | * collection. 87 | * 88 | * @since 1.0.0 89 | * @access private 90 | * @param array $hooks The collection of hooks that is being registered (that is, actions or filters). 91 | * @param string $hook The name of the WordPress filter that is being registered. 92 | * @param object $component A reference to the instance of the object on which the filter is defined. 93 | * @param string $callback The name of the function definition on the $component. 94 | * @param int $priority The priority at which the function should be fired. 95 | * @param int $accepted_args The number of arguments that should be passed to the $callback. 96 | * @return array The collection of actions and filters registered with WordPress. 97 | */ 98 | private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) { 99 | 100 | $hooks[] = array( 101 | 'hook' => $hook, 102 | 'component' => $component, 103 | 'callback' => $callback, 104 | 'priority' => $priority, 105 | 'accepted_args' => $accepted_args 106 | ); 107 | 108 | return $hooks; 109 | 110 | } 111 | 112 | /** 113 | * Register the filters and actions with WordPress. 114 | * 115 | * @since 1.0.0 116 | */ 117 | public function run() { 118 | 119 | foreach ( $this->filters as $hook ) { 120 | add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 121 | } 122 | 123 | foreach ( $this->actions as $hook ) { 124 | add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] ); 125 | } 126 | 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /includes/class-acf-form-shortcode.php: -------------------------------------------------------------------------------- 1 | 29 | */ 30 | class Acf_Form_Shortcode { 31 | 32 | /** 33 | * The loader that's responsible for maintaining and registering all hooks that power 34 | * the plugin. 35 | * 36 | * @since 1.0.0 37 | * @access protected 38 | * @var Acf_Form_Shortcode_Loader $loader Maintains and registers all hooks for the plugin. 39 | */ 40 | protected $loader; 41 | 42 | /** 43 | * The unique identifier of this plugin. 44 | * 45 | * @since 1.0.0 46 | * @access protected 47 | * @var string $plugin_name The string used to uniquely identify this plugin. 48 | */ 49 | protected $plugin_name; 50 | 51 | /** 52 | * The current version of the plugin. 53 | * 54 | * @since 1.0.0 55 | * @access protected 56 | * @var string $version The current version of the plugin. 57 | */ 58 | protected $version; 59 | 60 | /** 61 | * Define the core functionality of the plugin. 62 | * 63 | * Set the plugin name and the plugin version that can be used throughout the plugin. 64 | * Load the dependencies, define the locale, and set the hooks for the admin area and 65 | * the public-facing side of the site. 66 | * 67 | * @since 1.0.0 68 | */ 69 | public function __construct() { 70 | 71 | $this->plugin_name = 'acf-form-shortcode'; 72 | $this->version = '1.0.0'; 73 | 74 | $this->load_dependencies(); 75 | $this->set_locale(); 76 | $this->define_admin_hooks(); 77 | $this->define_public_hooks(); 78 | 79 | } 80 | 81 | /** 82 | * Load the required dependencies for this plugin. 83 | * 84 | * Include the following files that make up the plugin: 85 | * 86 | * - Acf_Form_Shortcode_Loader. Orchestrates the hooks of the plugin. 87 | * - Acf_Form_Shortcode_i18n. Defines internationalization functionality. 88 | * - Acf_Form_Shortcode_Admin. Defines all hooks for the admin area. 89 | * - Acf_Form_Shortcode_Public. Defines all hooks for the public side of the site. 90 | * 91 | * Create an instance of the loader which will be used to register the hooks 92 | * with WordPress. 93 | * 94 | * @since 1.0.0 95 | * @access private 96 | */ 97 | private function load_dependencies() { 98 | 99 | /** 100 | * The class responsible for orchestrating the actions and filters of the 101 | * core plugin. 102 | */ 103 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-acf-form-shortcode-loader.php'; 104 | 105 | /** 106 | * The class responsible for defining internationalization functionality 107 | * of the plugin. 108 | */ 109 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-acf-form-shortcode-i18n.php'; 110 | 111 | /** 112 | * The class responsible for defining all actions that occur in the admin area. 113 | */ 114 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-acf-form-shortcode-admin.php'; 115 | 116 | /** 117 | * The class responsible for defining all actions that occur in the public-facing 118 | * side of the site. 119 | */ 120 | require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-acf-form-shortcode-public.php'; 121 | 122 | $this->loader = new Acf_Form_Shortcode_Loader(); 123 | 124 | } 125 | 126 | /** 127 | * Define the locale for this plugin for internationalization. 128 | * 129 | * Uses the Acf_Form_Shortcode_i18n class in order to set the domain and to register the hook 130 | * with WordPress. 131 | * 132 | * @since 1.0.0 133 | * @access private 134 | */ 135 | private function set_locale() { 136 | 137 | $plugin_i18n = new Acf_Form_Shortcode_i18n(); 138 | 139 | $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' ); 140 | 141 | } 142 | 143 | /** 144 | * Register all of the hooks related to the admin area functionality 145 | * of the plugin. 146 | * 147 | * @since 1.0.0 148 | * @access private 149 | */ 150 | private function define_admin_hooks() { 151 | 152 | $plugin_admin = new Acf_Form_Shortcode_Admin( $this->get_plugin_name(), $this->get_version() ); 153 | 154 | //Adds our shortcode 155 | add_shortcode( 'show_acf_form' , array($plugin_admin, 'show_acf_form') ); 156 | 157 | } 158 | 159 | /** 160 | * Register all of the hooks related to the public-facing functionality 161 | * of the plugin. 162 | * 163 | * @since 1.0.0 164 | * @access private 165 | */ 166 | private function define_public_hooks() { 167 | 168 | $plugin_public = new Acf_Form_Shortcode_Public( $this->get_plugin_name(), $this->get_version() ); 169 | 170 | $this->loader->add_filter( 'acf/update_value', $plugin_public, 'acf_kses_post', 10, 1); 171 | $this->loader->add_action( 'wp', $plugin_public, 'enqueue_acf_form', 15 ); 172 | 173 | 174 | } 175 | 176 | /** 177 | * Run the loader to execute all of the hooks with WordPress. 178 | * 179 | * @since 1.0.0 180 | */ 181 | public function run() { 182 | $this->loader->run(); 183 | } 184 | 185 | /** 186 | * The name of the plugin used to uniquely identify it within the context of 187 | * WordPress and to define internationalization functionality. 188 | * 189 | * @since 1.0.0 190 | * @return string The name of the plugin. 191 | */ 192 | public function get_plugin_name() { 193 | return $this->plugin_name; 194 | } 195 | 196 | /** 197 | * The reference to the class that orchestrates the hooks with the plugin. 198 | * 199 | * @since 1.0.0 200 | * @return Acf_Form_Shortcode_Loader Orchestrates the hooks of the plugin. 201 | */ 202 | public function get_loader() { 203 | return $this->loader; 204 | } 205 | 206 | /** 207 | * Retrieve the version number of the plugin. 208 | * 209 | * @since 1.0.0 210 | * @return string The version number of the plugin. 211 | */ 212 | public function get_version() { 213 | return $this->version; 214 | } 215 | 216 | } 217 | -------------------------------------------------------------------------------- /includes/index.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Acf_Form_Shortcode_Public { 24 | 25 | /** 26 | * The ID of this plugin. 27 | * 28 | * @since 1.0.0 29 | * @access private 30 | * @var string $plugin_name The ID of this plugin. 31 | */ 32 | private $plugin_name; 33 | 34 | /** 35 | * The version of this plugin. 36 | * 37 | * @since 1.0.0 38 | * @access private 39 | * @var string $version The current version of this plugin. 40 | */ 41 | private $version; 42 | 43 | /** 44 | * Initialize the class and set its properties. 45 | * 46 | * @since 1.0.0 47 | * @param string $plugin_name The name of the plugin. 48 | * @param string $version The version of this plugin. 49 | */ 50 | public function __construct( $plugin_name, $version ) { 51 | 52 | $this->plugin_name = $plugin_name; 53 | $this->version = $version; 54 | 55 | } 56 | 57 | 58 | /** 59 | * Enqueues acf_form_header() if the shortcode can be found in the_content 60 | * 61 | * @since 1.0.0 62 | */ 63 | public function enqueue_acf_form(){ 64 | 65 | if( is_admin() ) 66 | return; 67 | 68 | global $post; 69 | if( has_shortcode( $post->post_content, 'show_acf_form' ) ){ 70 | acf_form_head(); 71 | 72 | } 73 | 74 | } 75 | 76 | 77 | /** 78 | * Runs ACF Through kses to avoid XSS hacks 79 | * 80 | * @since 1.0.0 81 | */ 82 | public function acf_kses_post( $value ){ 83 | // is array 84 | if( is_array($value) ) { 85 | return array_map(array($this, 'acf_kses_post'), $value); 86 | 87 | } 88 | 89 | // return 90 | return wp_kses_post( $value ); 91 | 92 | } 93 | 94 | 95 | } 96 | -------------------------------------------------------------------------------- /public/index.php: -------------------------------------------------------------------------------- 1 |