public function check_default($current_id) { global $wpdb; $query = $wpdb->prepare("SELECT `default_theme`FROM " . $wpdb->prefix . WDI_THEME_TABLE . " WHERE id='%d'", $current_id); $row = WDILibrary::objectToArray($wpdb->get_row($query)); return $row['default_theme']; }
function wdi_feed($atts, $widget_params = '') { ob_start(); wdi_load_frontend_scripts(); wdi_load_frontend_styles(); require_once WDI_DIR . '/framework/WDILibrary.php'; global $wdi_feed_counter; $attributes = shortcode_atts(array('id' => 'no_id'), $atts); if ($attributes['id'] == 'no_id') { return __('Invalid shortcode', "wdi"); } //including feed model require_once WDI_DIR . '/admin/models/WDIModelFeeds_wdi.php'; $feed_model = new WDIModelFeeds_wdi(); //getting all feed information from db $feed_row = WDILibrary::objectToArray($feed_model->get_feed_row($attributes['id'])); //checking if access token is not set or removed display proper error message global $wdi_options; if (!isset($wdi_options['wdi_access_token']) || $wdi_options['wdi_access_token'] == '') { return __('Access Token is invalid, please get it again ', "wdi"); die; } if (!isset($feed_row) || $feed_row == NULL) { return __('Feed Doesn\'t exists ', "wdi"); die; } $feed_row['widget'] = false; if ($widget_params != '' && $widget_params['widget'] == true) { $feed_row['widget'] = true; $feed_row['number_of_photos'] = (string) $widget_params['widget_image_num']; $feed_row['show_likes'] = (string) $widget_params['widget_show_likes_and_comments']; $feed_row['show_comments'] = (string) $widget_params['widget_show_likes_and_comments']; $feed_row['show_usernames'] = '0'; $feed_row['display_header'] = '0'; $feed_row['show_description'] = '0'; $feed_row['feed_display_view'] = 'widget'; $feed_row['number_of_columns'] = (string) $widget_params['number_of_columns']; } if (isset($feed_row['published']) && $feed_row['published'] === '0') { return __('Unable to display unpublished feed ', "wdi"); die; } //checking feed type and using proper MVC $feed_type = isset($feed_row['feed_type']) ? $feed_row['feed_type'] : ''; switch ($feed_type) { case 'thumbnails': //including thumbnails controller require_once WDI_DIR . '/frontend/controllers/WDIControllerThumbnails_view.php'; $controller = new WDIControllerThumbnails_view(); $controller->execute($feed_row, $wdi_feed_counter); $wdi_feed_counter++; break; case 'image_browser': //including thumbnails controller require_once WDI_DIR . '/frontend/controllers/WDIControllerImageBrowser_view.php'; $controller = new WDIControllerImageBrowser_view(); $controller->execute($feed_row, $wdi_feed_counter); $wdi_feed_counter++; break; default: return __('Invalid feed type', "wdi"); } global $wdi_options; if (isset($wdi_options['wdi_custom_css'])) { ?> <style> <?php echo $wdi_options['wdi_custom_css']; ?> </style> <?php } if (isset($wdi_options['wdi_custom_js'])) { ?> <script> <?php echo stripcslashes($wdi_options['wdi_custom_js']); ?> </script> <?php } return ob_get_clean(); }
private function duplicate_tabels($theme_id) { global $wpdb; if ($theme_id) { $theme_row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . WDI_THEME_TABLE . ' where id="%d"', $theme_id)); } if ($theme_row) { $duplicate_values = WDILibrary::objectToArray($theme_row); unset($duplicate_values['id']); $duplicate_values['default_theme'] = 0; $save = $wpdb->insert($wpdb->prefix . WDI_THEME_TABLE, $duplicate_values, $this->data_format); $new_theme_id = $wpdb->get_var('SELECT MAX(id) FROM ' . $wpdb->prefix . WDI_THEME_TABLE); } return array('id' => $new_theme_id, "msg" => $save); }
private function check_settings($settings) { $settings = WDILibrary::objectToArray($settings); if (isset($settings['feed_users']) && count(explode(',', $settings['feed_users'])) > 1) { $settings['feed_users'] = explode(',', $settings['feed_users'])[0]; } if (isset($settings['theme_id']) && intval($settings['theme_id']) > 1) { $settings['theme_id'] = '1'; } if (isset($settings['feed_display_view']) && $settings['feed_display_view'] === 'infinite_scroll') { $settings['feed_display_view'] = 'load_more_btn'; } if (isset($settings['feed_type']) && $settings['feed_type'] === 'masonry' || $settings['feed_type'] === 'blog_style') { $settings['feed_type'] = 'thumbnails'; } if (isset($settings['popup_enable_filmstrip']) && $settings['popup_enable_filmstrip'] == '1') { $settings['popup_enable_filmstrip'] = '0'; } if (isset($settings['popup_filmstrip_height']) && $settings['popup_filmstrip_height'] != '70') { $settings['popup_filmstrip_height'] = '70'; } if (isset($settings['popup_enable_comment']) && $settings['popup_enable_comment'] == '1') { $settings['popup_enable_comment'] = '0'; } if (isset($settings['popup_enable_share_buttons']) && $settings['popup_enable_share_buttons'] == '1') { $settings['popup_enable_share_buttons'] = '0'; } if (isset($settings['popup_info_always_show']) && $settings['popup_info_always_show'] == '1') { $settings['popup_info_always_show'] = '0'; } if (isset($settings['popup_info_full_width']) && $settings['popup_info_full_width'] == '1') { $settings['popup_info_full_width'] = '0'; } if (isset($settings['popup_enable_info']) && $settings['popup_enable_info'] == '1') { $settings['popup_enable_info'] = '0'; } if (isset($settings['show_likes']) && $settings['show_likes'] == '1') { $settings['show_likes'] = '0'; } if (isset($settings['show_description']) && $settings['show_description'] == '1') { $settings['show_description'] = '0'; } if (isset($settings['show_comments']) && $settings['show_comments'] == '1') { $settings['show_comments'] = '0'; } $settings = WDILibrary::arrayToObject($settings); return $settings; }
public function get_theme_row($theme_id) { require_once WDI_DIR . '/admin/models/WDIModelThemes_wdi.php'; $theme_row = WDIModelThemes_wdi::get_theme_row($theme_id); return WDILibrary::objectToArray($theme_row); }
private function check_settings($settings) { $settings = WDILibrary::objectToArray($settings); if (isset($settings['feed_users'])) { $settings['feed_users'] = json_decode($settings['feed_users']); $settings['feed_users'] = json_encode(array($settings['feed_users'][0])); } if (isset($settings['theme_id']) && intval($settings['theme_id']) > 1) { $settings['theme_id'] = '1'; } if (isset($settings['feed_display_view']) && $settings['feed_display_view'] === 'infinite_scroll') { $settings['feed_display_view'] = 'load_more_btn'; } if (isset($settings['feed_type']) && $settings['feed_type'] === 'masonry' || $settings['feed_type'] === 'blog_style') { $settings['feed_type'] = 'thumbnails'; } if (isset($settings['popup_enable_filmstrip']) && $settings['popup_enable_filmstrip'] == '1') { $settings['popup_enable_filmstrip'] = '0'; } if (isset($settings['show_username_on_thumb']) && $settings['show_username_on_thumb'] == '1') { $settings['show_username_on_thumb'] = '0'; } if (isset($settings['conditional_filter_enable']) && $settings['conditional_filter_enable'] == '1') { $settings['conditional_filter_enable'] = '0'; } if (isset($settings['popup_filmstrip_height']) && $settings['popup_filmstrip_height'] != '70') { $settings['popup_filmstrip_height'] = '70'; } if (isset($settings['popup_enable_comment']) && $settings['popup_enable_comment'] == '1') { $settings['popup_enable_comment'] = '0'; } if (isset($settings['popup_enable_share_buttons']) && $settings['popup_enable_share_buttons'] == '1') { $settings['popup_enable_share_buttons'] = '0'; } $settings = WDILibrary::arrayToObject($settings); return $settings; }
private function duplicate_tabels($feed_id) { global $wpdb; if ($feed_id) { $feed_row = $wpdb->get_row($wpdb->prepare('SELECT * FROM ' . $wpdb->prefix . WDI_FEED_TABLE . ' where id="%d"', $feed_id)); } if ($feed_row) { $duplicate_values = WDILibrary::objectToArray($feed_row); unset($duplicate_values['id']); $save = $wpdb->insert($wpdb->prefix . WDI_FEED_TABLE, $duplicate_values, $this->dataFormat); $new_slider_id = $wpdb->get_var('SELECT MAX(id) FROM ' . $wpdb->prefix . WDI_FEED_TABLE); } return $new_slider_id; }
public function display() { $rows = WDILibrary::objectToArray($this->model->get_row_data()); wp_print_scripts('jquery'); ?> <style type="text/css"> .editor_popup_container{ font-family:'Open Sans', sans-serif; } .styled-select select { background: transparent; width: 200px; padding: 5px; font-size: 14px; line-height: 1; color:rgb(68, 68, 68); border-radius: 0; height: 34px; -webkit-appearance: none; } .wdi_editor_label{ color:rgb(68, 68, 68); font-size:14px; font-weight:600; font-family:'Open Sans', sans-serif; } .wdi_feed_info{ color:rgb(68, 68, 68); font-size:14px; font-weight:600; text-align: center; font-family:'Open Sans', sans-serif; width: 30%; margin-top: 10px; margin:0 auto; } .wdi_feed_thumb img{ max-height: 50px; max-width: 50px; width: auto; height: auto; } .table-cell{ display: table-cell; vertical-align: middle; } .table-row{ display: table-row; } .wdi_feed_thumb, .wdi_feed_name{ padding: 5px; } .wdi_editor_insert{ background: #00a0d2; border-color: #0073aa; -webkit-box-shadow: inset 0 1px 0 rgba( 120, 200, 230, 0.5), 0 1px 0 rgba( 0, 0, 0, 0.15 ); box-shadow: inset 0 1px 0 rgba( 120, 200, 230, 0.5 ), 0 1px 0 rgba( 0, 0, 0, 0.15 ); color: #fff; text-decoration: none; display: inline-block; text-align: right; height: 30px; line-height: 28px; padding: 0 12px 2px; border-radius: 5px; border: 1px solid #948888; } .wdi_editor_insert:hover{ cursor: pointer; } </style> <div id="wdi_editor_popup"> <div class="editor_popup_container styled-select"> <div class="wdi_feed_select table-row"> <label for="wdi_feed_select" class="wdi_editor_label table-cell"><?php _e('Select Feed:', 'wdi'); ?> </label> <span class="wdi_feed_thumb table-cell"></span> <span class="table-cell"><select name="wdi_feed_select" onchange="wdi_selectChange()" id="wdi_feed_select"> <?php foreach ($rows as $row) { ?> <option value="<?php echo $row['id']; ?> "><?php echo $row["feed_name"]; ?> </option> <?php } ?> </select></span> </div> <div style="text-align:right"> <div id="wdi_editor_insert_btn" class="wdi_editor_insert">Insert</div> </div> </div> </div> <script> <?php echo 'var wdi_feed_rows =' . json_encode($rows); ?> ; jQuery(document).ready(function(){ wdi_selectChange(jQuery('#wdi_feed_select')); jQuery('#wdi_editor_insert_btn').on('click',wdi_insert_shortcode); }); function wdi_selectChange(){ var current = jQuery("#wdi_feed_select").val(); for(var i = 0; i < wdi_feed_rows.length; i++){ if(wdi_feed_rows[i]['id'] == current){ var currentRow = wdi_feed_rows[i]; break; } } var thumbHtml = '<img src="'+currentRow['feed_thumb']+'">'; //var nameHtml = currentRow['feed_name']; var id_elem = jQuery('<input id="wdi_id" name="wdi_id" type="hidden"/>'); id_elem.val(currentRow['id']); jQuery('.wdi_feed_thumb').html(thumbHtml); jQuery('.wdi_feed_thumb').append(id_elem); //jQuery('.wdi_feed_info .wdi_feed_name').html(nameHtml); } function wdi_insert_shortcode() { if (document.getElementById("wdi_id").value) { window.parent.send_to_editor('[wdi_feed id="' + document.getElementById('wdi_id').value + '"]'); } window.parent.tb_remove(); } </script> <?php die; }
function form($instance, $id_title, $name_title, $id_feed_id, $name_feed_id, $id_img_number, $name_img_number, $id_show_likes_comments, $name_show_likes_comments, $id_number_of_columns, $name_number_of_columns) { $defaults = array('title' => 'Instagram Feed', 'feed_id' => $this->model->get_last_feed_id(), 'img_number' => 4, 'show_likes_comments' => 0, 'number_of_columns' => 1); require_once WDI_DIR . '/framework/WDILibrary.php'; $feeds = WDILibrary::objectToArray($this->model->get_feeds()); $instance = wp_parse_args((array) $instance, $defaults); ?> <p> <label for="<?php echo $id_title; ?> ">Title:</label> <input class="widefat" id="<?php echo $id_title; ?> " name="<?php echo $name_title; ?> '" type="text" value="<?php echo $instance['title']; ?> "/> </p> <p> <label for="<?php echo $id_feed_id; ?> ">Feed:</label> <select onchange="wdi_toggle(jQuery(this));" class="widefat" id="<?php echo $id_feed_id; ?> " name="<?php echo $name_feed_id; ?> '" type="text"?>"> <?php foreach ($feeds as $feed) { ?> <option <?php if ($instance['feed_id'] == $feed['id']) { echo 'selected'; } ?> value="<?php echo $feed['id']; ?> "><?php echo $feed['feed_name']; ?> </option> <?php } ?> </select> </p> <p class="wdi_number_of_columns"> <label for="<?php echo $id_number_of_columns; ?> ">Number of columns:</label> <select class="widefat" id="<?php echo $id_number_of_columns; ?> " name="<?php echo $name_number_of_columns; ?> '" type="text" > <?php for ($k = 1; $k <= 10; $k++) { ?> <option <?php if ($instance['number_of_columns'] == $k) { echo 'selected'; } ?> value="<?php echo $k; ?> "><?php echo $k; ?> </option> <?php } ?> </select> </p> <p> <label for="<?php echo $id_img_number; ?> ">How many images to show:</label> <input class="widefat" id="<?php echo $id_img_number; ?> " name="<?php echo $name_img_number; ?> '" type="text" value="<?php echo $instance['img_number']; ?> "/> </p> <p> <input <?php if ($instance['show_likes_comments'] == '1') { echo "checked"; } ?> class="widefat" id="<?php echo $id_show_likes_comments; ?> " name="<?php echo $name_show_likes_comments; ?> '" type="checkbox" value="<?php echo $instance['show_likes_comments']; ?> "/> <label for="<?php echo $id_show_likes_comments; ?> ">Show likes and comments</label> </p> <script> jQuery(document).ready(function(){ wdi_toggle(jQuery('#<?php echo $id_feed_id; ?> ')); }); var feed_list = <?php echo json_encode($feeds); ?> ; function wdi_toggle(select){ var id = select.val(); for(var i = 0 ; i < feed_list.length; i++){ if(feed_list[i]['id'] == id){ if(feed_list[i]['feed_type'] == 'blog_style'){ select.parent().parent().find('.wdi_number_of_columns').css('display','none'); }else{ select.parent().parent().find('.wdi_number_of_columns').css('display','block'); } } } } </script> <?php }