Beispiel #1
0
<?php

$authorized = false;
$plugin = new Libsyn\Service();
$sanitize = new Libsyn\Service\Sanitize();
$api = $plugin->getApis();
$render = true;
$error = false;
if (isset($_GET) && is_array($_GET)) {
    parse_str(http_build_query($_GET));
}
if (!isset($_POST['redirect_url'])) {
    if (isset($_GET)) {
        $redirectUri = get_site_url() . '/wp-admin/?' . http_build_query($_GET);
    } else {
        $redirectUri = get_site_url() . '/wp-admin/';
    }
} else {
    $redirectUri = $_POST['redirect_url'];
}
/* Handle saved api */
if ($api instanceof Libsyn\Api && !$api->isRefreshExpired()) {
    $refreshApi = $api->refreshToken();
    if ($refreshApi) {
        //successfully refreshed
        $api = $api->retrieveApiById($api->getPluginApiId());
    } else {
        //in case of a api call error...
        $handleApi = true;
        $clientId = !isset($clientId) ? $api->getClientId() : $clientId;
        $clientSecret = !isset($clientSecret) ? $api->getClientSecret() : $clientSecret;
function build_libsyn_includes_original($scope)
{
    return array(plugin_dir_path(__FILE__) . $scope . '/lib/' . 'Libsyn.php', plugin_dir_path(__FILE__) . $scope . '/lib/' . 'functions.php', plugin_dir_path(__FILE__) . $scope . '/lib/Libsyn/' . 'Api.php', plugin_dir_path(__FILE__) . $scope . '/lib/Libsyn/' . 'Post.php', plugin_dir_path(__FILE__) . $scope . '/lib/Libsyn/' . 'Defs.php', plugin_dir_path(__FILE__) . $scope . '/lib/Libsyn/' . 'Service.php', plugin_dir_path(__FILE__) . $scope . '/lib/Libsyn/' . 'Playlist.php', plugin_dir_path(__FILE__) . $scope . '/lib/Libsyn/' . 'Service/Importer.php', plugin_dir_path(__FILE__) . $scope . '/lib/Libsyn/' . 'Service/Integration.php', plugin_dir_path(__FILE__) . $scope . '/lib/Libsyn/' . 'Service/Playlist.php', plugin_dir_path(__FILE__) . $scope . '/lib/Libsyn/' . 'Service/Sanitize.php', plugin_dir_path(__FILE__) . $scope . '/lib/Libsyn/' . 'PlaylistWidget.php');
}
$plugin_list = get_option('active_plugins');
//if plugin is active declare plugin
if (in_array(LIBSYN_DIR . '/' . LIBSYN_DIR . '.php', $plugin_list)) {
    //$libsyn_admin_includes = build_libsyn_includes('admin'); //may be able to use this in the future but it is not working on php 5.3
    $libsyn_admin_includes = build_libsyn_includes_original('admin');
    //global $libsyn_admin_includes;
    foreach ($libsyn_admin_includes as $include) {
        require_once $include;
    }
    /* Declare Plugin */
    $plugin = new \Libsyn\Service();
    $hasApi = $plugin->getApis();
    if ($hasApi !== false) {
        add_action('add_meta_boxes_post', 'add_libsyn_post_meta');
        add_action('save_post', '\\Libsyn\\Post::handlePost', 10, 2);
        add_filter('show_post_locked_dialog', '__return_false');
        \Libsyn\Post::actionsAndFilters();
    }
    //playlist
    // add_action( 'widgets_init', function(){
    // register_widget( 'Libsyn\PlaylistWidget' );
    // });
    //playlist ajax
    // add_filter('query_vars','Libsyn\\Playlist::plugin_add_trigger_load_libsyn_playlist');
    // add_action('template_redirect', 'Libsyn\\Playlist::loadLibsynPlaylist');
    // add_filter('query_vars','Libsyn\\Playlist::plugin_add_trigger_load_playlist');
    // add_action('template_redirect', 'Libsyn\\Playlist::loadPlaylist');