예제 #1
0
function ft_op_init()
{
    if (!file_exists(get_template_directory() . '/ft-options.php')) {
        return;
    }
    //  If user can't edit theme options, exit
    if (!current_user_can('edit_theme_options')) {
        return;
    }
    // Load translation files
    load_plugin_textdomain('ft_optionsframework', false, dirname(plugin_basename(__FILE__)) . '/languages/');
    // 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 FT_OP();
    $options_framework->init();
    // Instantiate the options page.
    $options_framework_admin = new FT_OP_Admin();
    $options_framework_admin->init();
    // Instantiate the media uploader class
    $options_framework_media_uploader = new FT_OP_Media_Uploader();
    $options_framework_media_uploader->init();
}
 /**
  * Enqueue scripts for file uploader
  */
 function ft_op_media_scripts($hook)
 {
     $menu = FT_OP_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', get_template_directory_uri() . '/FT/plugin/options-framework/js/media-uploader.js', array('jquery'), FT_OP::VERSION);
     wp_enqueue_script('of-media-uploader');
     wp_localize_script('of-media-uploader', 'ft_op_l10n', array('upload' => __('Upload', 'optionsframework'), 'remove' => __('Remove', 'optionsframework')));
 }