Пример #1
0
/**
 * Hook to add javascript and css file for admin
 */
function videogallery_admin_init()
{
    global $wpdb;
    $db_version = 3.0;
    $vgOptions = get_option('video_gallery');
    if (false === $vgOptions || !isset($vgOptions['db_version']) || $vgOptions['db_version'] < $db_version) {
        if (!is_array($vgOptions)) {
            $vgOptions = array();
        }
        /** Call function to create channel tables */
        createChannelTables();
        /** Call function to create playlist tables */
        playlistTables();
        /** Call function to create watch history tables */
        watchHistoryTables();
        /** Call function to create watch later tables */
        watchLaterTables();
        /** Create required page for channel,playlist,watch later,watch history **/
        createPostPages();
        $query = 'ALTER TABLE ' . HDFLVVIDEOSHARE . ' MODIFY google_adsense_value INT( 3 ) NULL';
        $wpdb->query($query);
        $query = 'ALTER TABLE ' . HDFLVVIDEOSHARE . ' MODIFY google_adsense INT( 3 ) NULL';
        $wpdb->query($query);
        $query = 'ALTER TABLE ' . HDFLVVIDEOSHARE . ' MODIFY midrollads INT( 11 ) NULL';
        $wpdb->query($query);
        $query = 'ALTER TABLE ' . HDFLVVIDEOSHARE . ' MODIFY imaad INT( 11 ) NULL';
        $wpdb->query($query);
        $query = 'ALTER TABLE ' . HDFLVVIDEOSHARE . ' MODIFY prerollads VARCHAR(25) NULL';
        $wpdb->query($query);
        $query = 'ALTER TABLE ' . HDFLVVIDEOSHARE . ' MODIFY postrollads VARCHAR(25) NULL';
        $wpdb->query($query);
        $query = 'ALTER TABLE ' . WVG_VGADS . ' MODIFY impressionurl TEXT NULL';
        $wpdb->query($query);
        $query = 'ALTER TABLE ' . WVG_VGADS . ' MODIFY clickurl TEXT NULL';
        $wpdb->query($query);
        $query = 'ALTER TABLE ' . WVG_VGADS . ' CHANGE `file_path` `file_path` VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL';
        $wpdb->query($query);
        $query = 'ALTER TABLE ' . WVG_VGADS . ' CHANGE `title` `title` VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL';
        $wpdb->query($query);
        $vgOptions['db_version'] = $db_version;
        update_option('video_gallery', $vgOptions);
    }
    /** Include default WordPress jquery and sortable js files */
    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-sortable');
    /** Include plugin admin js file */
    wp_register_script('videogallery_jscss', plugins_url('admin/js/admin.min.js', __FILE__));
    wp_enqueue_script('videogallery_jscss');
    /** Include plugin sortorder js file */
    wp_register_script('videogallery_sortablejs', plugins_url('admin/js/vg_sortorder.js', __FILE__));
    wp_enqueue_script('videogallery_sortablejs');
    /** Include plugin admin settings css file */
    wp_register_style('videogallery_css1', plugins_url('admin/css/adminsettings.min.css', __FILE__));
    wp_enqueue_style('videogallery_css1');
}
Пример #2
0
/**
 * Install plugin tables and insert sample videos, playlist
 */
function videogallery_install()
{
    global $wpdb;
    /** Function to display instruction while plugin activation */
    update_option('video_gallery_adjustment_instruction', 'adjustment_setting');
    /** Function to display warning if videogallery folder is not created */
    update_option('video_gallery_folder_instruction', 'folder_setting');
    /** Initializing variable */
    $wfound = $pfound = $mfound = $rollfound = $tags = $settingsFound = $adsense = false;
    /** Looping to check whether the videogallery plugin tables are already exist */
    foreach ($wpdb->get_results('SHOW TABLES;', ARRAY_N) as $row) {
        /** Check video main table is exists */
        if ($row[0] == HDFLVVIDEOSHARE) {
            $wfound = true;
        }
        /** Check video playlsit is exists */
        if ($row[0] == WVG_PLAYLIST) {
            $pfound = true;
        }
        /** Check video media table is exists */
        if ($row[0] == WVG_MED2PLAY) {
            $mfound = true;
        }
        /** Check video ads table is exists */
        if ($row[0] == WVG_VGADS) {
            $rollfound = true;
        }
        /** Check video tags table is exists */
        if ($row[0] == WVG_TAGS) {
            $tags = true;
        }
        /** Check video settings table is exists */
        if ($row[0] == WVG_SETTINGS) {
            $settingsFound = true;
        }
        /** Check video google adsense table is exists */
        if ($row[0] == WVG_VGOOGLEADSENSE) {
            $adsense = true;
        }
    }
    /** Call function to create plugin tables */
    createTables($wfound, $pfound, $mfound, $tags);
    /** Call function to create video ads and google adsense table */
    createADsTable($rollfound, $adsense);
    /** Call function to create settings table */
    createSettingsTable($settingsFound);
    /** Call function to create video home, video more pages in admin while plugin installation */
    createVGPluginPages();
    /** Call function to create channel tables */
    createChannelTables();
    /** Call function to create playlist tables */
    playlistTables();
    /** Call function to create watch history tables */
    watchHistoryTables();
    /** Call function to create watch later tables */
    watchLaterTables();
    /** Create required page for channel,playlist,watch later,watch history **/
    createPostPages();
    /**
     * Call function to insert sample videos in videos table 
     * and create posts for the videos in posts table 
     */
    insertSampleVideos();
    /** Call function to insert sample playlist values and media table values */
    insertSampleCategories();
    /** Call function to insert settings data into db */
    insertSettingsTable();
    /** Update plugin and flush plugin rules */
    flush_rewrite_rules();
}