wpdb = $wpdb; load_plugin_textdomain( 'acf-field-migrator', false, '/advanced-custom-fields-migrator/languages/' ); add_action( 'added_option', array( &$this, 'force_autoload_no' ), 10, 2 ); if ( ! current_user_can( 'manage_options' ) ) return; $this->options_link = ''.__('Settings', 'acf-migrator').''; add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueues' ) ); add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) ); add_action( 'wp_ajax_acfmigrator', array( &$this, 'ajax_process_record' ) ); add_filter( 'plugin_action_links', array( &$this, 'add_plugin_action_links' ), 10, 2 ); } public function force_autoload_no( $option, $value ) { if ( ! get_acfm_options( 'force_autoload_no' ) ) return true; // Only for ACF fields - for now if ( ! preg_match( '#^_+\d+_[a-zA-Z](\w)+$#', $option ) ) return true; $result = $this->wpdb->update( $this->wpdb->options, array( 'autoload' => 'no' ), array( 'option_name' => $option ) ); return $result ? true : false; } // Display a Settings link on the main Plugins page public function add_plugin_action_links( $links, $file ) { if ( $file == plugin_basename( __FILE__ ) ) { array_unshift( $links, $this->options_link ); $link = ''.__('Migrate', 'acf-migrator').''; array_unshift( $links, $link ); } return $links; } // Register the management page public function add_admin_menu() { $this->menu_id = add_management_page( __( 'ACF Migration', 'acf-migrator' ), __( 'ACF Migration', 'acf-migrator' ), 'manage_options', 'acf-migrator', array(&$this, 'user_interface') ); add_action( 'admin_print_styles-' . $this->menu_id, array( &$this, 'styles' ) ); add_screen_meta_link( 'acf-migrator-options-link', __('ACF Migration Settings', 'acf-migrator'), admin_url('options-general.php?page=acf-migrator-options'), $this->menu_id, array('style' => 'font-weight: bold;') ); } public function styles() { wp_register_style( 'acf-migrator-admin', plugins_url( 'settings.css', __FILE__ ) ); wp_enqueue_style( 'acf-migrator-admin' ); } // Enqueue the needed Javascript and CSS public function admin_enqueues( $hook_suffix ) { if ( $hook_suffix != $this->menu_id ) return; // WordPress 3.1 vs older version compatibility if ( wp_script_is( 'jquery-ui-widget', 'registered' ) ) wp_enqueue_script( 'jquery-ui-progressbar', plugins_url( 'jquery-ui/jquery.ui.progressbar.min.js', __FILE__ ), array( 'jquery-ui-core', 'jquery-ui-widget' ), '1.8.6' ); else wp_enqueue_script( 'jquery-ui-progressbar', plugins_url( 'jquery-ui/jquery.ui.progressbar.min.1.7.2.js', __FILE__ ), array( 'jquery-ui-core' ), '1.7.2' ); wp_enqueue_style( 'jquery-ui-acfmigrator', plugins_url( 'jquery-ui/redmond/jquery-ui-1.7.2.custom.css', __FILE__ ), array(), '1.7.2' ); } public function user_interface() { echo <<