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, `youtubelink` varchar(255) 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); } add_option('youtubedb', 1); } register_activation_hook(__FILE__, 'aparg_addmyplugin'); function add_youtube_db() { global $wpdb; $table_name = $wpdb->prefix . "aparg_flexslider"; if (!get_option('youtubedb')) { $sq = "ALTER TABLE `" . $table_name . "` ADD `youtubelink` VARCHAR(255) NOT NULL"; $wpdb->query($sq); add_option('youtubedb', 1); } } add_action('admin_init', 'add_youtube_db'); /* 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-1.10.4.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']; $youtubelink = $_POST['tubelink']; $slides_titles = $_POST['title']; $desc_array = array(); $settings = $_POST['slide_options']; $settings['slider_width'] = (isset($_POST['slide_options']['slider_width_def'])) ? "" : trim($_POST['slide_options']['slider_width']); $settings['slider_height'] = (isset($_POST['slide_options']['slider_height_def'])) ? "" : trim($_POST['slide_options']['slider_height']); $settings['slider_width_def'] = (isset($_POST['slide_options']['slider_width_def'])) ? 1 : 0; $settings['slider_height_def'] = (isset($_POST['slide_options']['slider_height_def'])) ? 1 : 0; $settings['carousel'] = (isset($_POST['slide_options']['carousel'])) ? 1 : 0; $settings['animation'] = (isset($_POST['slide_options']['carousel'])) ? $_POST['slide_options']['animation'] : "slide"; $settings['animation'] = (!isset($_POST['slide_options']['carousel']) && $_POST['slide_options']['animation'] == 'fade') ? $_POST['slide_options']['animation'] : "slide"; $settings['randomize'] = (isset($_POST['slide_options']['randomize'])) ? 1 : 0; $settings['controlNav'] = (isset($_POST['slide_options']['controlNav'])) ? 1 : 0; $settings['directionNav'] = (isset($_POST['slide_options']['directionNav'])) ? 1 : 0; $settings['pauseOnHover'] = (isset($_POST['slide_options']['pauseOnHover'])) ? 1 : 0; $settings['autoPlay'] = (isset($_POST['slide_options']['autoPlay'])) ? 1 : 0; 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"; $slider_data[$key]['youtubelink'] = (isset($youtubelink[$key])) ? $youtubelink[$key] : ""; 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); $youtubelink = $value->youtubelink; $slider_content.= '| Click to change image'; $slider_content.= ''; $slider_content.= ' | '; $slider_content.= ' ';
$button_style = ($description[0] === "NULL") ? 'style="display:none;"' : '';
$slider_content.= '';
if ($youtubelink && $youtubelink != 'NULL') {
$slider_content.= ' '; $slider_content.= ''; $slider_content.= ' ';
$slider_content.= 'Please insert a valid youtube link '; } foreach ($description as $k => $val): if ($val != "NULL") { $slider_content.= ''; } endforeach; $slider_content.= ' | ![]() | ';
$slider_content.= '