PluginProbe
Advanced Forms for ACF / 1.0.0
Advanced Forms for ACF v1.0.0
1.9.0 1.9.1 1.9.2.1 1.9.3 1.9.3.1 1.9.3.2 1.9.3.3 1.9.3.4 1.9.3.5 1.9.3.6 1.9.3.7 1.9.3.8 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.3.1 1.0.3.2 1.0.3.3 1.0.4 1.1.0 1.1.1 1.2.0 1.3.0 All 51 releases
advanced-forms / advanced-forms.php

advanced-forms.php in Advanced Forms for ACF 1.0.0, at advanced-forms.php

221 lines 7.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Advanced Forms
4 Description: Flexible and developer-friendly forms with the power of Advanced Custom Fields.
5 Version: 1.0.0
6 Author: Fabian Lindfors
7 Copyright: Fabian Lindfors
8 Text Domain: advanced-forms
9 Domain Path: /language
10 */
11
12
13 class AF {
14
15 function __construct() {
16
17 add_action( 'plugins_loaded', array( $this, 'initialize_plugin' ), 10, 0 );
18
19 }
20
21
22 /**
23 * Initializes the plugin and makes sure ACF is installed
24 *
25 * @since 1.0.0
26 *
27 */
28 function initialize_plugin() {
29
30 add_action( 'admin_notices', array( $this, 'missing_acf_notice' ), 10, 0 );
31
32 if ( ! class_exists( 'acf_pro' ) ) {
33 return;
34 }
35
36
37 // Load translations
38 load_textdomain( 'advanced-forms', plugin_dir_path( __FILE__ ) . 'language/advanced-forms-' . get_locale() . '.mo' );
39
40
41 // API functions
42 include( plugin_dir_path( __FILE__ ) . 'api/api-forms.php' );
43 include( plugin_dir_path( __FILE__ ) . 'api/api-entries.php' );
44
45 // Core functionality
46 include( plugin_dir_path( __FILE__ ) . 'core/core-forms.php' );
47 include( plugin_dir_path( __FILE__ ) . 'core/core-emails.php' );
48 include( plugin_dir_path( __FILE__ ) . 'core/core-entries.php' );
49
50 // ACF additions (fields, location rules, etc.)
51 include( plugin_dir_path( __FILE__ ) . 'acf/acf-additions.php' );
52
53 // Admin
54 include( plugin_dir_path( __FILE__ ) . 'admin/admin-forms.php' );
55 include( plugin_dir_path( __FILE__ ) . 'admin/admin-entries.php' );
56 include( plugin_dir_path( __FILE__ ) . 'admin/admin-emails.php' );
57
58
59 // Include assets
60 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ), 10, 0 );
61 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ), 10, 0 );
62
63
64 // Register basic post types
65 add_action( 'init', array( $this, 'register_post_types' ), 10, 0 );
66
67
68 // Action used to register forms
69 do_action( 'af/register_forms' );
70
71 }
72
73
74 function missing_acf_notice() {
75
76 if ( ! class_exists( 'acf_pro' ) ) {
77
78 echo sprintf( '<div class="notice notice-error is-dismissible"><p>%s</p></div>', 'Couldn\'t find ACF 5. Advanced Forms requires ACF 5 to function correctly.' );
79
80 }
81
82 }
83
84
85 /**
86 * Enqueues admin styles
87 *
88 * @since 1.0.0
89 *
90 */
91 function enqueue_admin_styles() {
92 wp_enqueue_style( 'af-admin-style', plugin_dir_url( __FILE__ ) . 'assets/css/admin.css' );
93
94 }
95
96
97 /**
98 * Enqueues global styles
99 *
100 * @since 1.0.0
101 *
102 */
103 function enqueue_styles() {
104 wp_enqueue_style( 'af-form-style', plugin_dir_url( __FILE__ ) . 'assets/css/form.css' );
105
106 }
107
108
109 /**
110 * Register custom post types, forms and entries
111 *
112 * @since 1.0.0
113 */
114 function register_post_types() {
115
116 // Form post type
117 $labels = array(
118 'name' => _x( 'Forms', 'Post Type General Name', 'advanced-forms' ),
119 'singular_name' => _x( 'Form', 'Post Type Singular Name', 'advanced-forms' ),
120 'menu_name' => __( 'Forms', 'advanced-forms' ),
121 'name_admin_bar' => __( 'Form', 'advanced-forms' ),
122 'archives' => __( 'Item Archives', 'advanced-forms' ),
123 'parent_item_colon' => __( 'Parent Item:', 'advanced-forms' ),
124 'all_items' => __( 'Forms', 'advanced-forms' ),
125 'add_new_item' => __( 'Add New Form', 'advanced-forms' ),
126 'add_new' => __( 'Add New', 'advanced-forms' ),
127 'new_item' => __( 'New Form', 'advanced-forms' ),
128 'edit_item' => __( 'Edit Form', 'advanced-forms' ),
129 'update_item' => __( 'Update Form', 'advanced-forms' ),
130 'view_item' => __( 'View Form', 'advanced-forms' ),
131 'search_items' => __( 'Search Form', 'advanced-forms' ),
132 'not_found' => __( 'Not found', 'advanced-forms' ),
133 'not_found_in_trash' => __( 'Not found in Trash', 'advanced-forms' ),
134 'featured_image' => __( 'Featured Image', 'advanced-forms' ),
135 'set_featured_image' => __( 'Set featured image', 'advanced-forms' ),
136 'remove_featured_image' => __( 'Remove featured image', 'advanced-forms' ),
137 'use_featured_image' => __( 'Use as featured image', 'advanced-forms' ),
138 'insert_into_item' => __( 'Insert into form', 'advanced-forms' ),
139 'uploaded_to_this_item' => __( 'Uploaded to this item', 'advanced-forms' ),
140 'items_list' => __( 'Forms list', 'advanced-forms' ),
141 'items_list_navigation' => __( 'Forms list navigation', 'advanced-forms' ),
142 'filter_items_list' => __( 'Filter forms list', 'advanced-forms' ),
143 );
144 $args = array(
145 'label' => __( 'Form', 'advanced-forms' ),
146 'description' => __( 'Form', 'advanced-forms' ),
147 'labels' => $labels,
148 'supports' => array( 'title', ),
149 'hierarchical' => false,
150 'public' => true,
151 'show_ui' => true,
152 'show_in_menu' => true,
153 'menu_icon' => 'dashicons-list-view',
154 'menu_position' => 80,
155 'show_in_admin_bar' => true,
156 'show_in_nav_menus' => true,
157 'can_export' => true,
158 'has_archive' => false,
159 'exclude_from_search' => false,
160 'publicly_queryable' => false,
161 'rewrite' => false,
162 'capability_type' => 'page',
163 );
164 register_post_type( 'af_form', $args );
165
166
167 // Entry post type
168 $labels = array(
169 'name' => _x( 'Entries', 'Post Type General Name', 'advanced-forms' ),
170 'singular_name' => _x( 'Entry', 'Post Type Singular Name', 'advanced-forms' ),
171 'menu_name' => __( 'Entries', 'advanced-forms' ),
172 'name_admin_bar' => __( 'Entry', 'advanced-forms' ),
173 'archives' => __( 'Entry Archives', 'advanced-forms' ),
174 'parent_item_colon' => __( 'Parent Entry:', 'advanced-forms' ),
175 'all_items' => __( 'Entries', 'advanced-forms' ),
176 'add_new_item' => __( 'Add New Entry', 'advanced-forms' ),
177 'add_new' => __( 'Add New', 'advanced-forms' ),
178 'new_item' => __( 'New Entry', 'advanced-forms' ),
179 'edit_item' => __( 'Edit Entry', 'advanced-forms' ),
180 'update_item' => __( 'Update Entry', 'advanced-forms' ),
181 'view_item' => __( 'View Entry', 'advanced-forms' ),
182 'search_items' => __( 'Search Entry', 'advanced-forms' ),
183 'not_found' => __( 'Not found', 'advanced-forms' ),
184 'not_found_in_trash' => __( 'Not found in Trash', 'advanced-forms' ),
185 'featured_image' => __( 'Featured Image', 'advanced-forms' ),
186 'set_featured_image' => __( 'Set featured image', 'advanced-forms' ),
187 'remove_featured_image' => __( 'Remove featured image', 'advanced-forms' ),
188 'use_featured_image' => __( 'Use as featured image', 'advanced-forms' ),
189 'insert_into_item' => __( 'Insert into entry', 'advanced-forms' ),
190 'uploaded_to_this_item' => __( 'Uploaded to this entries', 'advanced-forms' ),
191 'items_list' => __( 'Entries list', 'advanced-forms' ),
192 'items_list_navigation' => __( 'Entries list navigation', 'advanced-forms' ),
193 'filter_items_list' => __( 'Filter entries list', 'advanced-forms' ),
194 );
195 $args = array(
196 'label' => __( 'Entry', 'advanced-forms' ),
197 'description' => __( 'Entry', 'advanced-forms' ),
198 'labels' => $labels,
199 'supports' => array( 'title', ),
200 'hierarchical' => false,
201 'public' => true,
202 'show_ui' => true,
203 'show_in_menu' => 'edit.php?post_type=af_form',
204 'menu_icon' => 'dashicons-list-view',
205 'menu_position' => 80,
206 'show_in_admin_bar' => true,
207 'show_in_nav_menus' => true,
208 'can_export' => true,
209 'has_archive' => false,
210 'exclude_from_search' => false,
211 'publicly_queryable' => false,
212 'rewrite' => false,
213 'capability_type' => 'page',
214 );
215 register_post_type( 'af_entry', $args );
216
217 }
218
219 }
220
221 new AF();