芝麻web文件管理V1.00
编辑当前文件:/home/p/r/i/prismawe/clients/_aspiconfort.fr/httpdocs/wp-content/plugins/widgetkit/widgetkit.php
boot(); $app->on('init', function ($event, $app) { // set the API Keys $app['config']->set('apikey', get_option('yootheme_apikey')); $app['config']->set('googlemapseapikey', get_option('yootheme_googlemapseapikey')); // system editor setting $app['config']->set('system_editor', get_option('yootheme_system_editor')); // init 1click Update $app['update']->register('widgetkit', 'plugin', 'http://yootheme.com/api/update/widgetkit_wp', array('key' => $app['config']->get('apikey'))); }); // set theme support $app->on('view', function ($event, $app) { $app['config']->set('theme.support', current_theme_supports('widgetkit')); // add to admin styles if ($app['admin']) { $app['styles']->add('widgetkit-wordpress', 'assets/css/wordpress.css'); } }); // init on admin ajax add_action('admin_init', function () use ($app) { $app['config']->set('settings-page', admin_url('options-general.php?page=widgetkit-config')); if (defined('DOING_AJAX') && $app['request']->get('action') == $app['name']) { $app->trigger('init.admin', array($app)); } }); // init on certain admin screens add_action('current_screen', function ($screen) use ($app) { if (in_array($screen->base, array('post', 'customize', 'widgets', 'toplevel_page_widgetkit'))) { add_action('admin_enqueue_scripts', function () use ($screen) { if ($screen->base != 'toplevel_page_widgetkit') { return; } // create dummy editor to initialize tinyMCE on widgetkit admin page add_action('in_admin_footer', function() { echo '
'; wp_editor('', 'editor-dummy-widgetkit', array( 'wpautop' => false, 'media_buttons' => true, 'textarea_name' => 'textarea-dummy-widgetkit', 'textarea_rows' => 10, 'editor_class' => 'horizontal', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true )); echo '
'; }); wp_enqueue_media(); }); $app['scripts']->add('widgetkit-wordpress', 'assets/js/wordpress.js', array('widgetkit-application')); $app->trigger('init.admin', array($app)); add_action('in_widget_form', function ($widget, $return, $instance) use ($app) { if ($widget->id_base == 'text') { $id = "widget-{$widget->id}-text"; echo '
Widgetkit
'; } }, 10, 3); } }); // add to admin menu add_action('admin_menu', function () use ($app) { add_action('load-toplevel_page_widgetkit', function () use ($app) { $response = $app->handle(null, false); add_action('toplevel_page_widgetkit', function () use ($response) { $response->send(); }); }); add_action('load-settings_page_' . $app['name'] . '-config', function () use ($app) { if ($app['request']->get('action') === 'save' and wp_verify_nonce($app['request']->get('_wpnonce'))) { $config = $app['request']->get('config', array()); // save the YOOtheme API key outside the config if (isset($config['apikey'])) { update_option('yootheme_apikey', $config['apikey']); } // save the Google API key outside the config if (isset($config['googlemapseapikey'])) { update_option('yootheme_googlemapseapikey', $config['googlemapseapikey']); } // save editor setting if (isset($config['system_editor'])) { update_option('yootheme_system_editor', $config['system_editor']); } else { update_option('yootheme_system_editor', 0); } $app['config']->set('apikey', get_option('yootheme_apikey')); $app['config']->set('googlemapseapikey', get_option('yootheme_googlemapseapikey')); $app['config']->set('system_editor', get_option('yootheme_system_editor')); } }); add_menu_page('Widgetkit', 'Widgetkit', 'manage_widgetkit', $app['name'], function () { }, 'dashicons-admin-widgetkit', '50'); add_options_page('Widgetkit Settings', 'Widgetkit', 'manage_options', $app['name'] . '-config', function () use ($app) { require(__DIR__ . '/widgetkit-config.php'); }); }); // add settings link add_filter('plugin_action_links_' . plugin_basename(__FILE__), function ($links) use ($app) { array_unshift($links, '
' . $app['translator']->trans('Settings') . '
'); return $links; }); // add media buttons add_action('media_buttons_context', function ($context) use ($app) { return $context . '
Widgetkit
'; }); // add shortcode add_shortcode('widgetkit', function ($attrs, $content, $code) use ($app) { return $app->renderWidget($attrs); }); // add widget add_action('widgets_init', function () { require_once(__DIR__ . '/widgetkit-widget.php'); register_widget('WP_Widget_Widgetkit'); }); // apply shortcodes in text widgets add_filter('widget_text', 'do_shortcode'); // enable svg upload add_filter('upload_mimes', function ($mimes) use ($app) { if ($app['admin']) { $mimes['svg'] = 'image/svg+xml'; $mimes['svgz'] = 'image/svg+xml'; } return $mimes; }); $roles = array('administrator', 'editor', 'author'); // add activation hook register_activation_hook(__FILE__, function () use ($app, $roles) { $oldVersion = get_option('widgetkit.version'); if ($oldVersion && version_compare($oldVersion, '2.2.0', '<')) { $update = require($app['path'] . '/updates/2.2.0.php'); $update->run(); } foreach ($roles as $name) { get_role($name)->add_cap('manage_widgetkit'); } $app->install(); update_option('widgetkit.version', '2.8.0'); }); // add deactivation hook register_deactivation_hook(__FILE__, function () use ($app, $roles) { foreach ($roles as $name) { get_role($name)->remove_cap('manage_widgetkit'); } });