function wpr_optionsframework_init() { // If user can't edit theme options, exit if (!current_user_can('edit_theme_options')) { return; } // Loads the required Options Framework classes. require plugin_dir_path(__FILE__) . 'includes/class-options-framework.php'; require plugin_dir_path(__FILE__) . 'includes/class-options-framework-admin.php'; require plugin_dir_path(__FILE__) . 'includes/class-options-interface.php'; require plugin_dir_path(__FILE__) . 'includes/class-options-media-uploader.php'; require plugin_dir_path(__FILE__) . 'includes/class-options-sanitization.php'; // Instantiate the main plugin class. $options_framework = new Wpr_Options_Framework(); $options_framework->init(); // Instantiate the options page. $Wpr_Options_Framework_Admin = new Wpr_Options_Framework_Admin(); $Wpr_Options_Framework_Admin->init(); // Instantiate the media uploader class $options_framework_media_uploader = new Wpr_Options_Framework_Media_Uploader(); $options_framework_media_uploader->init(); }
/** * Enqueue scripts for file uploader */ function wpr_optionsframework_media_scripts($hook) { $menu = Wpr_Options_Framework_Admin::menu_settings(); if (substr($hook, -strlen($menu['menu_slug'])) !== $menu['menu_slug']) { return; } if (function_exists('wp_enqueue_media')) { wp_enqueue_media(); } wp_register_script('of-media-uploader', WPR_OPTIONS_FRAMEWORK_DIRECTORY . 'js/media-uploader.js', array('jquery'), Wpr_Options_Framework::VERSION); wp_enqueue_script('of-media-uploader'); wp_localize_script('of-media-uploader', 'wpr_optionsframework_l10n', array('upload' => __('Upload', 'textdomain'), 'remove' => __('Remove', 'textdomain'))); }