Exemple #1
0
        function form($instance)
        {
            $instance = wp_parse_args((array) $instance, array('title' => __("RoyalSlider", "new_royalslider")));
            ?>
        <p>
            <label for="<?php 
            echo $this->get_field_id('title');
            ?>
"><?php 
            _e("Title", "new_royalslider");
            ?>
:</label>
            <input id="<?php 
            echo $this->get_field_id('title');
            ?>
" name="<?php 
            echo $this->get_field_name('title');
            ?>
" value="<?php 
            echo $instance['title'];
            ?>
" />
        </p>
        <p>
            <label for="<?php 
            echo $this->get_field_id('royalslider_id');
            ?>
"><?php 
            _e("Select slider to add", "new_royalslider");
            ?>
:</label>
            <select id="<?php 
            echo $this->get_field_id('royalslider_id');
            ?>
" name="<?php 
            echo $this->get_field_name('royalslider_id');
            ?>
" style="width:100%;">
                <?php 
            global $wpdb;
            $table = NewRoyalSliderMain::get_sliders_table_name();
            $qstr = " \n\t\t\t\t\tSELECT id, name FROM {$table} WHERE active=1  AND type!='gallery'\n\t\t\t\t";
            $res = $wpdb->get_results($qstr, ARRAY_A);
            $curr_id = isset($instance['royalslider_id']) ? $instance['royalslider_id'] : '';
            if (is_array($res)) {
                foreach ($res as $key => $slider_data) {
                    $id = $slider_data['id'];
                    $selected = '';
                    if ($id == $curr_id) {
                        $selected = ' selected="selected"';
                    }
                    $name = isset($slider_data['name']) ? $slider_data['name'] . ' ' : '';
                    echo '<option value="' . $id . '"' . $selected . '>' . $name . '#' . $id . '</option>';
                }
            }
            ?>
            </select>
        </p>
    <?php 
        }
 function __construct($is_add_new)
 {
     $this->is_add_new = $is_add_new;
     $this->slider_type = isset($_REQUEST['rstype']) ? esc_html($_REQUEST['rstype']) : '';
     $this->parsed_options = null;
     if (!$is_add_new && isset($_REQUEST['id'])) {
         global $wpdb;
         $this->slider_id = (int) $_REQUEST['id'];
         $table = NewRoyalSliderMain::get_sliders_table_name();
         $this->res = $wpdb->get_results($wpdb->prepare("\n                        SELECT * FROM {$table} WHERE id=%d\n                    ", $this->slider_id), ARRAY_A);
         if (isset($this->res[0])) {
             $this->res = $this->res[0];
             $this->parsed_options = json_decode($this->res['options'], ARRAY_A);
         }
     }
     $this->build_view();
 }
 function ajax_save_slider()
 {
     check_ajax_referer('new_royalslider_save_ajax_nonce');
     global $wpdb;
     $data = stripslashes_deep($_POST);
     $options = isset($_POST['options']) ? json_encode($data['options']) : '';
     $slides = isset($_POST['slides']) ? json_encode($data['slides']) : '';
     $table_name = NewRoyalSliderMain::get_sliders_table_name();
     //$type = strtolower($type);
     $values = array('name' => $data['name'], 'type' => $data['slider_type'], 'skin' => $data['skin'], 'slides' => $slides, 'options' => $options, 'template' => $data['template'], 'template_html' => $data['template_html']);
     $format = array('%s', '%s', '%s', '%s', '%s', '%s', '%s');
     if (isset($_POST['isCreate']) && $_POST['isCreate'] == 'true') {
         $wpdb->insert($table_name, $values, $format);
         echo $wpdb->insert_id;
         if ($data['slider_type'] == 'nextgen') {
             update_option('new_royalslider_ng_slider_id', $wpdb->insert_id);
         }
     } else {
         if (isset($_POST['slider_id'])) {
             $wpdb->update($table_name, $values, array('ID' => $_POST['slider_id']), $format, array('%d'));
             NewRoyalSliderMain::delete_cache_for($_POST['slider_id'], $data['slider_type']);
             echo 'saved';
             if ($data['slider_type'] == 'nextgen') {
                 update_option('new_royalslider_ng_slider_id', (int) $_POST['slider_id']);
             }
         } else {
             echo 'incorrect id';
         }
     }
     die;
 }
 private function duplicate_slider($id)
 {
     global $wpdb;
     $table = NewRoyalSliderMain::get_sliders_table_name();
     $res = $wpdb->get_results($wpdb->prepare("\n                    SELECT * FROM {$table} WHERE id=%d\n                ", $id), ARRAY_A);
     $res = $res[0];
     $res['name'] = (isset($res['name']) && $res['name'] != '' ? $res['name'] . ' ' : '') . __('(copy of ', 'new_royalslider') . '#' . $id . ')';
     unset($res['id']);
     $wpdb->insert($table, $res);
     return $wpdb->insert_id;
 }
 function activate_db()
 {
     $curr_ver = get_option("new_royalslider_version");
     if ($curr_ver != NEW_ROYALSLIDER_WP_VERSION) {
         global $wpdb;
         $charset_collate = '';
         if (!empty($wpdb->charset)) {
             $charset_collate = " DEFAULT CHARACTER SET {$wpdb->charset}";
         }
         if (!empty($wpdb->collate)) {
             $charset_collate .= " COLLATE {$wpdb->collate}";
         }
         $table_name = NewRoyalSliderMain::get_sliders_table_name();
         $sql = "CREATE TABLE IF NOT EXISTS " . $table_name . " (\r\n\t\t\t\t\t  id \t\t\t\tmediumint(9) NOT NULL AUTO_INCREMENT,\t\r\n\t\t\t\t\t  active            tinyint(1) not null default 1,\r\n\t\t\t\t\t  type \t\t\t\tvarchar(100) NOT NULL,\t\t\t\t  \r\n\t\t\t\t\t  name \t\t\t\tvarchar(100) NOT NULL,\r\n\t\t\t\t\t  skin \t\t\t\tvarchar(100) NOT NULL,\r\n\t\t\t\t\t  template          varchar(100) NOT NULL,\r\n\t\t\t\t\t  slides\t\t\tlongtext NOT NULL, \r\n\t\t\t\t\t  options\t\t\tmediumtext NOT NULL, \r\n\t\t\t\t\t  template_html\t\tmediumtext NOT NULL, \r\n\r\n\t\t\t\t\t  PRIMARY KEY (id)\r\n\t\t\t\t)" . $charset_collate . ";";
         $wpdb->query($sql);
         // increase size of fields in old versions
         if ($curr_ver && version_compare($curr_ver, '3.0.3', '<')) {
             $upd_sql = "\r\n\t\t\t\tALTER TABLE {$table_name}\r\n\t\t\t\t\tMODIFY type varchar(100),\r\n\t\t\t\t\tMODIFY name varchar(100),\r\n\t\t\t\t\tMODIFY skin varchar(100),\r\n\t\t\t\t\tMODIFY template varchar(100)\r\n\t\t\t\t";
             $wpdb->query($upd_sql);
         }
         $options = array('timeout' => 10, 'headers' => array('Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'), 'User-Agent' => 'WordPress/' . get_bloginfo("version") . ' RoyalSlider/' . NEW_ROYALSLIDER_WP_VERSION, 'Referer' => home_url()));
         update_option("new_royalslider_version", NEW_ROYALSLIDER_WP_VERSION);
     }
 }
<?php

if (!defined('ABSPATH')) {
    exit;
}
if (!defined('WP_UNINSTALL_PLUGIN')) {
    exit;
}
global $wpdb;
require_once 'classes/NewRoyalSliderMain.php';
$slider_table = NewRoyalSliderMain::get_sliders_table_name();
$wpdb->query("DROP TABLE IF EXISTS {$slider_table}");
delete_option("new_royalslider_version");
delete_option('new_royalslider_config');
delete_option('new_royalslider_anim_block_classes');
delete_option('new_royalslider_instagram_oauth_token');
delete_option('new_royalslider_ng_slider_id');
 function activate_db()
 {
     $curr_ver = get_option("new_royalslider_version");
     if ($curr_ver != NEW_ROYALSLIDER_WP_VERSION) {
         global $wpdb;
         $charset_collate = '';
         if (!empty($wpdb->charset)) {
             $charset_collate = " DEFAULT CHARACTER SET {$wpdb->charset}";
         }
         if (!empty($wpdb->collate)) {
             $charset_collate .= " COLLATE {$wpdb->collate}";
         }
         $table_name = NewRoyalSliderMain::get_sliders_table_name();
         $sql = "CREATE TABLE IF NOT EXISTS " . $table_name . " (\n\t\t\t\t\t  id \t\t\t\tmediumint(9) NOT NULL AUTO_INCREMENT,\t\n\t\t\t\t\t  active            tinyint(1) not null default 1,\n\t\t\t\t\t  type \t\t\t\tvarchar(100) NOT NULL,\t\t\t\t  \n\t\t\t\t\t  name \t\t\t\tvarchar(100) NOT NULL,\n\t\t\t\t\t  skin \t\t\t\tvarchar(100) NOT NULL,\n\t\t\t\t\t  template          varchar(100) NOT NULL,\n\t\t\t\t\t  slides\t\t\tlongtext NOT NULL, \n\t\t\t\t\t  options\t\t\tmediumtext NOT NULL, \n\t\t\t\t\t  template_html\t\tmediumtext NOT NULL, \n\n\t\t\t\t\t  PRIMARY KEY (id)\n\t\t\t\t)" . $charset_collate . ";";
         $wpdb->query($sql);
         // increase size of fields in old versions
         if ($curr_ver && version_compare($curr_ver, '3.0.3', '<')) {
             $upd_sql = "\n\t\t\t\tALTER TABLE {$table_name}\n\t\t\t\t\tMODIFY type varchar(100),\n\t\t\t\t\tMODIFY name varchar(100),\n\t\t\t\t\tMODIFY skin varchar(100),\n\t\t\t\t\tMODIFY template varchar(100)\n\t\t\t\t";
             $wpdb->query($upd_sql);
         }
         update_option("new_royalslider_version", NEW_ROYALSLIDER_WP_VERSION);
     }
 }