function mf_add_js() { global $mf_domain; if (is_admin()) { //this scripts only will be added on the admin area wp_enqueue_script('jquery.validate', MF_BASENAME . 'js/third_party/jquery.validate.min.js', array('jquery')); wp_enqueue_script('jquery.metadata', MF_BASENAME . 'js/third_party/jquery.metadata.js', array('jquery')); wp_enqueue_script('mf_admin', MF_BASENAME . 'js/mf_admin.js', array('jquery.validate', 'jquery.metadata', 'jquery')); // add stringToSlug if (isset($_GET['mf_action']) && in_array($_GET['mf_action'], array('add_field', 'edit_field', 'add_post_type', 'add_group', 'add_custom_taxonomy'))) { wp_enqueue_script('jquery.stringToSlug', MF_BASENAME . 'js/third_party/jquery.stringToSlug.min.js', array('mf_admin')); } //and this scripts only will be added on the default categories if (!empty($_GET['mf_action']) && $_GET['mf_action'] == "set_categories") { wp_enqueue_script('mf_set_categories', MF_BASENAME . 'js/mf_set_categories.js', array('mf_admin')); } //and this scripts only will be added on the post types section if (!empty($_GET['mf_section']) && $_GET['mf_section'] == "mf_posttype") { wp_enqueue_script('mf_posttype', MF_BASENAME . 'js/mf_posttypes.js', array('mf_admin')); wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox'); } if (!empty($_GET['page']) && $_GET['page'] == "mf_dispatcher") { wp_enqueue_script('thickbox'); wp_enqueue_style('thickbox'); } //and this scripts only will be added on the custom taxonomy section if (!empty($_GET['mf_section']) && $_GET['mf_section'] == "mf_custom_taxonomy") { wp_enqueue_script('mf_taxonomy', MF_BASENAME . 'js/mf_taxonomy.js', array('mf_admin')); } //Adding the files for the sort feature of the custom fields if (!empty($_GET['mf_section']) && $_GET['mf_section'] == 'mf_custom_fields' && (!empty($_GET['mf_action']) && $_GET['mf_action'] == 'fields_list')) { wp_enqueue_script('mf_sortable_fields', MF_BASENAME . 'js/mf_posttypes_sortable.js', array('jquery-ui-sortable')); } // scripts needed for the custom groups if (!empty($_GET['mf_section']) && $_GET['mf_section'] == 'mf_custom_group') { wp_enqueue_script('mf_custom_group', MF_BASENAME . 'js/mf_custom_group.js', array('mf_admin')); } //Adding Css files for the post-new.php section (where is created a new post in wp) if (strstr($_SERVER['REQUEST_URI'], 'post-new.php') !== FALSE || strstr($_SERVER['REQUEST_URI'], 'wp-admin/post.php') !== FALSE) { /* Load JS and CSS for post page */ $css_js = new mf_post(); $css_js->load_js_css_base(); $css_js->load_js_css_fields(); $css_js->general_option_multiline(); $css_js->set_categories(); } } }
public function field_duplicate($data) { $group_id = (int) $data['group_id']; $group_index = (int) $data['group_index']; $field_id = (int) $data['field_id']; $field_index = (int) $data['field_index']; $mf_post = new mf_post(); $mf_post->mf_ajax_duplicate_field($group_id, $group_index, $field_id, $field_index); }