prefix . "aparg_flexslider"; $options_table_name = $wpdb->prefix . "aparg_flexslider_options"; $sliders_table_name = $wpdb->prefix . "aparg_flexslider_sliders"; $MSQL = "show tables like '".$table_name; $mSQL = "show tables like '".$options_table_name; $msql = "show tables like '".$sliders_table_name; require_once(ABSPATH . "wp-admin/includes/upgrade.php"); if($wpdb->get_var($MSQL) != $table_name) { $sql = "CREATE TABLE IF NOT EXISTS `".$table_name."` ( `id` int(3) NOT NULL AUTO_INCREMENT, `slide_id` int(3) NOT NULL, `slide_url` varchar(255) NOT NULL, `slide_title` varchar(255) NOT NULL, `description` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; /* Including dbDelta function for working with DB*/ dbDelta($sql); } if($wpdb->get_var($mSQL) != $options_table_name) { $Sql = "CREATE TABLE IF NOT EXISTS `".$options_table_name."` ( `id` int(9) NOT NULL AUTO_INCREMENT, `slider_id` int(3) NOT NULL, `slider_option_name` varchar(30) NOT NULL, `slider_option` varchar(30) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; /* Including dbDelta function for working with DB*/ dbDelta($Sql); } if($wpdb->get_var($msql) != $sliders_table_name) { $SQl = "CREATE TABLE IF NOT EXISTS `".$sliders_table_name."` ( `slider_id` int(3) NOT NULL, `slider_name` varchar(255) NOT NULL, PRIMARY KEY (`slider_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8"; /* Including dbDelta function for working with DB */ dbDelta($SQl); } } register_activation_hook(__FILE__, 'aparg_addmyplugin'); /* Creating Menus */ function aparg_slider_menu() { /* Adding menus */ add_menu_page('APARG Slider', 'APARG Slider', 8, 'apargslider', 'aparg_flex_slider', plugins_url('aparg-slider/images/logo.png')); } add_action( 'admin_init', 'aparg_my_plugin_scripts' ); add_action('admin_menu', 'aparg_slider_menu'); // **** // function apargslider_contextual_help( $contextual_help) { global $current_screen; $cont_help = "
Hi, this is a APARG Slider help.
". "To use our slider plugin at first you should add a slider by clicking on the '+' tab.
". "Then you'll see default slider settings on right side and blank area on the left side where you can add slides(click 'Add Images') with their descriptions('Add Description').
". "After that save current slide information
". "Our slider plugin advantages". "Note: If all descriptions are empty their options(background and text color) are inactive.
"; switch( $current_screen->id ) { case 'toplevel_page_apargslider' : get_current_screen()->add_help_tab( array( 'id' => 'apargslider-help-tab', 'title' => __( 'APARG Slider Help' ), 'content' => __( $cont_help) )); break; } return $contextual_help; } add_filter('contextual_help', 'apargslider_contextual_help'); // **** // function aparg_my_plugin_scripts() { if (is_admin() && isset($_GET['page']) && $_GET['page'] == 'apargslider') { global $wp_scripts; wp_enqueue_script('jquery'); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_script('jquery-ui-dialog'); $ui = $wp_scripts->query('jquery-ui-core'); wp_enqueue_style('jquery-dialog-style', plugins_url("css/jquery-ui/jquery-ui-$ui->ver.css", __FILE__ )); wp_enqueue_media(); wp_register_script('cpicker_scripts', plugins_url('colorpicker/js/colorpicker.js', __FILE__ )); wp_enqueue_script('cpicker_scripts'); wp_register_style('cpicker_styles', plugins_url('colorpicker/css/colorpicker.css', __FILE__ )); wp_enqueue_style( 'cpicker_styles'); wp_register_style('custom_styles', plugins_url('css/plugin_styles.css', __FILE__ ),false,false,'all'); wp_enqueue_style( 'custom_styles'); wp_register_script('custom_scripts', plugins_url('js/main.js', __FILE__ ),array( 'jquery','jquery-ui-core')); wp_enqueue_script('custom_scripts'); //Add script to use alternatively media query in IE8 wp_register_script('respond_scripts', plugins_url('js/respond.min.js', __FILE__ )); wp_enqueue_script('respond_scripts'); } } function aparg_make_slider_content($slider_id) { $uploadfiles = $_POST['img']; $slides_titles = $_POST['title']; $desc_array = array(); $settings = $_POST['slide_options']; if(isset($_POST['desc']) && !empty($_POST['desc'])) { foreach($_POST['desc'] as $key => $desc) { $desc_array[$key] = implode('%APARG%',$desc); } $slider_data = array(); global $check; global $wpdb; foreach($uploadfiles as $key => $slide_images): $slider_data[$key]["slide_url"] = str_replace(get_site_url(),"",$slide_images); $slider_data[$key]["slide_title"] = $slides_titles[$key]; $slider_data[$key]["description"] = (array_key_exists($key,$desc_array))?$desc_array[$key]:"NULL"; endforeach; $j = 0; foreach($settings as $key => $slider_option): $slider_options[$j]["slider_option_name"] = $key; $slider_options[$j]["slider_option"] = $slider_option; $j++; endforeach; $get_content = get_slider_data($slider_id); add_slides($table_name = $wpdb->prefix . "aparg_flexslider", $slider_data,$slider_id); add_slider_options($tablename = $wpdb->prefix . "aparg_flexslider_options", $slider_options,$slider_id); $slider_content = aparg_show_saved_slider($slider_id); $slider_settings = get_slider_settings($slider_id); } if(isset($slider_settings) && !empty($slider_settings) && isset($slider_content) && !empty($slider_content)) { require_once("slider_form.php"); echo ""; } else { require_once("slider_form.php"); } } function aparg_show_saved_slider($slider_id) { $get_content = get_slider_data($slider_id); $slider_content = ""; if(isset($get_content) && !empty($get_content)) { foreach($get_content as $key => $value) { $description = explode('%APARG%',$value->description); $slider_content.= '| Click to change image'; $slider_content.= ''; $slider_content.= ' | '; $slider_content.= ' ';
$button_style = ($description[0]==="NULL")?'style="display:none;"':'';
$slider_content.= ' '; foreach($description as $k => $val): if($val!="NULL") { $slider_content.= ''; } endforeach; $slider_content.= ' | ![]() | ';
$slider_content.= '