function epl_wpimport_register_fields() { global $epl_ai_meta_fields, $epl_wpimport; // Initialize EPL WP All Import Pro add-on. $epl_wpimport = new RapidAddon('Easy Property Listings Custom Fields', 'epl_wpimport_addon'); if (!empty($epl_ai_meta_fields)) { foreach ($epl_ai_meta_fields as $epl_meta_box) { if (!empty($epl_meta_box['groups'])) { foreach ($epl_meta_box['groups'] as $group) { $epl_wpimport->add_title($group['label'], $group['label']); $fields = $group['fields']; $fields = array_filter($fields); if (!empty($fields)) { foreach ($fields as $field) { switch ($field['type']) { case 'textarea': $epl_wpimport->add_field($field['name'], $field['label'], 'textarea'); break; case 'url': case 'date': case 'sold-date': case 'sold-date': case 'auction-date': case 'decimal': case 'number': case 'checkbox': case 'checkbox_single': $epl_wpimport->add_field($field['name'], $field['label'], 'text'); break; case 'select': case 'radio': $opts = isset($field['opts']) ? $field['opts'] : array(); if (!empty($opts)) { foreach ($opts as $opt_key => &$opt_value) { if (is_array($opt_value)) { $opts[$opt_key] = $opt_value['label']; } } } $epl_wpimport->add_field($field['name'], $field['label'], 'radio', array()); break; default: $type = in_array($field['type'], array('text', 'hidden')) ? 'text' : $field['type']; $epl_wpimport->add_field($field['name'], $field['label'], $type); break; } } } } } } // Register Import Function $epl_wpimport->set_import_function('epl_wpimport_import_function'); // display a dismiss able notice warning the user to install WP All Import to use the add-on. // Customize the notice text by passing a string to admin_notice(), i.e. admin_notice("XYZ Theme recommends you install WP All Import (free | pro)") //$epl_wpimport->admin_notice("Easy Property Listings requires <a href='http://wordpress.org/plugins/wp-all-import'>WP All Import Pro</a>"); // the add-on will run for all themes/post types if no arguments are passed to run() $epl_wpimport->run(array("post_types" => epl_get_core_post_types())); } }
<?php /* Plugin Name: Yoast SEO Add-On Description: A complete example add-on for importing data to certain Yoast SEO fields. Version: 1.0 Author: WP All Import */ include "rapid-addon.php"; $yoast_seo_addon = new RapidAddon('Yoast SEO Add-On', 'yoast_seo_addon'); $yoast_seo_addon->add_field('yoast_wpseo_title', 'SEO Title', 'text'); $yoast_seo_addon->add_field('yoast_wpseo_metadesc', 'Meta Description', 'text'); $yoast_seo_addon->add_field('yoast_wpseo_meta-robots-noindex', 'Meta Robots Index', 'radio', array('' => 'default', '1' => 'noindex', '2' => 'index')); $yoast_seo_addon->add_field('yoast_wpseo_opengraph-image', 'Facebook Image', 'image'); $yoast_seo_addon->set_import_function('yoast_seo_addon_import'); // display a dismissable notice warning the user to install WP All Import to use the add-on. // Customize the notice text by passing a string to admin_notice(), i.e. admin_notice("XYZ Theme recommends you install WP All Import (free | pro)") $yoast_seo_addon->admin_notice(); // the add-on will run for all themes/post types if no arguments are passed to run() $yoast_seo_addon->run(); function yoast_seo_addon_import($post_id, $data, $import_options) { global $yoast_seo_addon; if ($yoast_seo_addon->can_update_meta('_yoast_wpseo_title', $import_options)) { update_post_meta($post_id, '_yoast_wpseo_title', $data['yoast_wpseo_title']); } if ($yoast_seo_addon->can_update_meta('_yoast_wpseo_metadesc', $import_options)) { update_post_meta($post_id, '_yoast_wpseo_metadesc', $data['yoast_wpseo_metadesc']); } if ($yoast_seo_addon->can_update_meta('_yoast_wpseo_meta-robots-noindex', $import_options)) { update_post_meta($post_id, '_yoast_wpseo_meta-robots-noindex', $data['yoast_wpseo_meta-robots-noindex']);
} // Update language do_action('wpml_set_element_language_details', $set_language_args); update_slug($post, $slug, $language); } function update_slug($post_object, $slug, $language) { // The post slug was changed (because of duplicate) if ($post_object->post_name != $slug) { wp_update_post(array('ID' => $post_object->ID, 'post_name' => $slug)); } } $multilingual_import_addon = new RapidAddon('Multilingual Import Add-On', 'multilingual_import_addon'); $multilingual_import_addon->add_field('multilingual_import_language', 'Entry Language', 'text'); $multilingual_import_addon->add_field('multilingual_import_common_id', 'Entry Common ID', 'text'); $multilingual_import_addon->set_import_function('multilingual_addon_import'); // display a dismissable notice warning the user to install WP All Import to use the add-on. // Customize the notice text by passing a string to admin_notice(), i.e. admin_notice("XYZ Theme recommends you install WP All Import (free | pro)") $multilingual_import_addon->admin_notice(); // the add-on will run for all themes/post types if no arguments are passed to run() $multilingual_import_addon->run(); function multilingual_addon_import($post_id, $data, $import_options, $articleData) { global $multilingual_import_addon; $language = $data['multilingual_import_language']; $common_id = $data['multilingual_import_common_id']; if ($multilingual_import_addon->can_update_meta('_multilingual_entry_language', $import_options)) { echo 'Updating META'; update_post_meta($post_id, '_multilingual_entry_language', $language); } if ($multilingual_import_addon->can_update_meta('_multilingual_entry_common_id', $import_options)) {
if ($pods_fields) { foreach ($pods_fields as $pods_field) { $fields_array[] = $vipp_addon_free->add_field('vippfree' . $my_pod->post_name . $pods_field->post_name, $pods_field->post_title, 'text', null, $pods_field->post_content); $my_fields[$my_pod->post_name][$pods_field->post_name] = ''; //original field name as array key to avoid field name conflicts. } } $vipp_addon_free->add_options(null, $my_pod->post_title . ' Fields', $fields_array); } } } $vipp_addon_free->add_field('vipp_my_pod_name', 'Drag and drop to fields of your content type to import. <a href="http://vipp.com.au"> Upgrade for relationship fields matching, media upload, WooCommerce customer import and more premium features</a>. ', 'text', null, "Drag and drop data from the right hand side to the data type you are importing. Fields of other content types under this section will be ignored. "); //start of pro features //end of pro features //print_r($my_fields); $vipp_addon_free->set_import_function('pods_addon_import_free'); $vipp_addon_free->admin_notice('This add-on plugin requires WP All Import <a href="http://www.wpallimport.com/" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>, and the <a href="https://wordpress.org/plugins/pods/"> Pods - Custom Content Types and Fields </a> plugin. ', array("plugins" => array("pods/init.php"))); $vipp_addon_free->run(array("plugins" => array("pods/init.php"), "post_types" => $my_pod_array)); function pods_addon_import_free($post_id, $data, $import_options) { global $vipp_addon_free, $wpdb, $my_fields; //$my_pod_name = $data['vipp_my_pod_name']; $my_pod_name = $import_options->options['custom_type']; //echo '<br>' . $my_pod_name; $vipp_addon_free->log('- Processing custom fields of pods custom type name: `' . $my_pod_name . '`'); $save = array(); //echo '<pre>'; //print_r($data); //print_r($my_fields[$my_pod_name]);
$jobify_addon->disable_default_images(); $jobify_addon->add_field('_job_location', 'Location', 'text', null, 'Leave this blank if location is not important'); $jobify_addon->add_field('_company_name', 'Company Name', 'text'); $jobify_addon->add_field('_company_tagline', 'Company Tagline', 'text'); $jobify_addon->add_field('_company_description', 'Company Description', 'text'); $jobify_addon->add_field('_application', 'Application Email or URL', 'text', null, 'This field is required for the "application" area to appear beneath the listing.'); $jobify_addon->add_field('_company_website', 'Company Website', 'text'); $jobify_addon->add_field('_company_logo', 'Company Logo', 'image'); $jobify_addon->add_field('company_featured_image', 'Featured Image', 'image'); // field is _company_video, will 'image' add_field support videos? $jobify_addon->add_field('video_type', 'Company Video', 'radio', array('external' => array('Externally Hosted', $jobify_addon->add_field('_company_video_url', 'Video URL', 'text')), 'local' => array('Locally Hosted', $jobify_addon->add_field('_company_video_id', 'Upload Video', 'file')))); $jobify_addon->add_field('_job_expires', 'Listing Expiry Date', 'text', null, 'Import date in any strtotime compatible format.'); $jobify_addon->add_field('_filled', 'Filled', 'radio', array('0' => 'No', '1' => 'Yes'), 'Filled listings will no longer accept applications.'); $jobify_addon->add_field('_featured', 'Featured Listing', 'radio', array('0' => 'No', '1' => 'Yes'), 'Featured listings will be sticky during searches, and can be styled differently.'); $jobify_addon->add_options(null, 'Social Media Options', array($jobify_addon->add_field('_company_facebook', 'Company Facebook', 'text'), $jobify_addon->add_field('_company_twitter', 'Company Twitter', 'text'), $jobify_addon->add_field('_company_linkedin', 'Company LinkedIn', 'text'), $jobify_addon->add_field('_company_google', 'Company Google+', 'text'))); $jobify_addon->set_import_function('jobify_addon_import'); $jobify_addon->admin_notice('The Jobify Add-On requires WP All Import <a href="http://www.wpallimport.com/order-now/?utm_source=free-plugin&utm_medium=dot-org&utm_campaign=jobify" target="_blank">Pro</a> or <a href="http://wordpress.org/plugins/wp-all-import" target="_blank">Free</a>, and the <a href="https://astoundify.com/go/wp-all-import-buy-jobify/">Jobify</a> theme.', array('themes' => array('Jobify'))); $jobify_addon->run(array('themes' => array('Jobify'), 'post_types' => array('job_listing'))); function jobify_addon_import($post_id, $data, $import_options) { global $jobify_addon; // all fields except for slider and image fields $fields = array('_job_location', '_company_name', '_company_tagline', '_company_description', '_application', '_company_website', '_filled', '_featured', '_company_facebook', '_company_twitter', '_company_linkedin', '_company_google'); // update everything in fields arrays foreach ($fields as $field) { if ($jobify_addon->can_update_meta($field, $import_options)) { update_post_meta($post_id, $field, $data[$field]); } } // set featured image $field = 'company_featured_image';