base_prefix . 'arete_buddypress_smiley_settings'; $smiley_save = $wpdb->base_prefix . 'arete_buddypress_smileys'; $smiley_bp = $wpdb->base_prefix . 'arete_buddypress_smileys_manage'; $charset_collate = ''; if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } if($wpdb->get_var("SHOW TABLES LIKE '$settings'") != $settings) { $sql = "CREATE TABLE $settings ( id mediumint(11) NOT NULL AUTO_INCREMENT, type VARCHAR(255) DEFAULT '' NOT NULL, value VARCHAR(255) DEFAULT '' NOT NULL, UNIQUE KEY id (id) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } if($wpdb->get_var("SHOW TABLES LIKE '$smiley_save'") != $smiley_save) { $smiley = "CREATE TABLE $smiley_save ( id mediumint(11) NOT NULL AUTO_INCREMENT, image VARCHAR(255) DEFAULT '' NOT NULL, name VARCHAR(255) DEFAULT '' NOT NULL, front VARCHAR(255) DEFAULT '' NOT NULL, UNIQUE KEY id (id) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($smiley); } if($wpdb->get_var("SHOW TABLES LIKE '$smiley_bp'") != $smiley_bp) { $bp_smiley = "CREATE TABLE $smiley_bp( id mediumint(11) NOT NULL AUTO_INCREMENT, smiley_id VARCHAR(255) DEFAULT '' NOT NULL, user_id VARCHAR(255) DEFAULT '' NOT NULL, activity_id VARCHAR(255) DEFAULT '' NOT NULL, timestamp VARCHAR(11) DEFAULT '' NOT NULL, UNIQUE KEY id (id) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($bp_smiley); } update_option('version', $version); } } /********* function used for inserting default values in database tables on activation *************/ function arete_plugin_smileys() { GLOBAL $wpdb; $settings = $wpdb->base_prefix . 'arete_buddypress_smileys'; $bp_setting = $wpdb->base_prefix . 'arete_buddypress_smiley_settings'; $enable_query = ai_bp_reactions_check_existance($settings, 'Like', 'like.png'); $enable_query = ai_bp_reactions_check_existance($settings, 'Love', 'love.png'); $enable_query = ai_bp_reactions_check_existance($settings, 'Thankful', 'thankful.png'); $enable_query = ai_bp_reactions_check_existance($settings, 'Ha Ha', 'haha.png'); $enable_query = ai_bp_reactions_check_existance($settings, 'Wow', 'wow.png'); $enable_query = ai_bp_reactions_check_existance($settings, 'Sad', 'sad.png'); $enable_query = ai_bp_reactions_check_existance($settings, 'Angry', 'angry.png'); $enable_query = ai_bp_reactions_settings_check_existance($bp_setting , 'favorite', "0"); } /**************** function for check reactions value already exist in table. ***************/ function ai_bp_reactions_check_existance($table, $name, $image) { GLOBAL $wpdb; $exist=$wpdb->get_var("SELECT id from $table WHERE name='$name'"); if(empty($exist)) { $wpdb->insert($table, array( 'id' => "", 'name' =>$name, 'image' =>$image, 'front' => 'checked' ), array( '%d', '%s', '%s', '%s' )); } } /**************** function for check if value already exist in table. ***************/ function ai_bp_reactions_settings_check_existance($table, $condition, $value) { GLOBAL $wpdb; $condition =trim($condition); $exist=$wpdb->get_var("SELECT id from $table WHERE type='$condition'"); if(empty($exist)) { $wpdb->insert($table,array('id'=>"",'type'=>$condition,'value'=>$value),array('%d','%s','%s')); } } /********* function used for drop and truncate database tables on deactivation *************/ function arete_plugin_smileys_truncate() { global $wpdb; $settings = $wpdb->base_prefix . 'arete_buddypress_smileys'; $bp_setting = $wpdb->base_prefix . 'arete_buddypress_smiley_settings'; $wpdb->query("DROP TABLE IF EXISTS $settings"); $wpdb->query("DROP TABLE IF EXISTS $bp_setting"); } /********* function for enqueue js files *************/ function arete_load_ai_bp_js_smiley() { wp_enqueue_script( 'jquery' ); wp_enqueue_script('arete-custom_ai_bp_reactions', plugins_url('js/ai_bp_reactions_custom.js', dirname(__FILE__))); } /********* function for enqueue style files *************/ function arete_load_ai_bp_css_smiley() { wp_enqueue_style('arete-custom-style_admin', plugins_url('css/ai_bp_reactions_custom.css', dirname(__FILE__))); } add_action('admin_enqueue_scripts', 'arete_load_ai_bp_js_smiley'); add_action('admin_enqueue_scripts', 'arete_load_ai_bp_css_smiley'); /********* function for enqueue style and js files in front end *************/ function ai_bp_smiley_pro_f_scripts() { wp_enqueue_script( 'jquery' ); wp_enqueue_script('arete-act-react-jquery-mobile', plugins_url('js/ai_bp_reactions_jquery.touch.min.js', dirname(__FILE__))); wp_enqueue_script('arete-custom_ai_front_smiley', plugins_url('js/ai_bp_reactions_custom.js', dirname(__FILE__))); wp_enqueue_script('arete-custom_ai_front_tipsy', plugins_url('js/ai_bp_reactions_jquery.tipsy-min.js', dirname(__FILE__))); wp_enqueue_script('arete-custom_ai_bp_reactions_lightbox', plugins_url('js/ai_bp_reactions_vex.combined.min.js', dirname(__FILE__))); wp_enqueue_style('arete-custom-style_front_smiley', plugins_url('css/ai_bp_reactions_custom.css', dirname(__FILE__))); wp_enqueue_style('arete-custom-style_tipsy', plugins_url('css/ai_bp_reactions_tipsy.min.css', dirname(__FILE__))); wp_enqueue_style('arete-custom_ai_bp_reactions_lightbox_main_css', plugins_url('css/ai_bp_reactions_vex.css', dirname(__FILE__))); wp_enqueue_style('arete-custom_ai_bp_reactions_lightbox_css', plugins_url('css/ai_bp_reactions_vex-theme-flat-attack.css', dirname(__FILE__))); } add_action('wp_enqueue_scripts', 'ai_bp_smiley_pro_f_scripts'); /***** function for animation css according to reaction count ******/ function ai_bp_main_animation_css() { GLOBAL $wpdb; if ( ! is_admin() ) { $html=""; $ob_temp= new ai_bp_manage_reactions_temp; $total_reactions=json_decode(ai_bp_get_main_animation_css_mod()); $single_count=$total_reactions->reactions_count; for($i=1; $i<=$single_count; $i++) { $animation_style=json_decode($ob_temp->ai_bp_reactions_animation_css_temp($i)); $html.= $animation_style->html; } return $html; } } /********* wordpress class extended to show smileys in admin panel form where administrator manage smileys *************/ class ai_bp_activity_list_table_class_extend extends WP_List_Table { public $main_data; public $type; /** ************************************************************************ * Normally we would be querying data from a database and manipulating that * for use in your list table. For this example, we're going to simplify it * slightly and create a pre-built array. Think of this as the data that might * be returned by $wpdb->query(). * * @var array **************************************************************************/ public static function ai_get_smiley($per_page, $page_number = 1) { global $wpdb; $main_data = array(); $result = ""; $sql = "SELECT * FROM {$wpdb->base_prefix}arete_buddypress_smileys"; if (!empty($_REQUEST['orderby'])) { $sql .= ' ORDER BY ' . esc_sql($_REQUEST['orderby']); $sql .= !empty($_REQUEST['order']) ? ' ' . esc_sql($_REQUEST['order']) : ' ASC'; } if (!empty($per_page)) { $sql .= " LIMIT $per_page"; $sql .= ' OFFSET ' . ($page_number - 1) * $per_page; } $result = $wpdb->get_results($sql); $count =1; foreach ($result as $val) { $image = $val->image; $image_plugin = plugins_url('activity-reactions-for-buddypress/img/') . $image; $main_data[] = array( 'smiley' => $image_plugin, 'name' => $val->name, 'id' => $val->id, 'action'=> $val->front, 'serial' =>$count ); $count++; } return $main_data; } public static function ai_bp_reactions_delete_this_record($main_id, $type) { global $wpdb; $db = $wpdb->base_prefix . 'arete_buddypress_smileys'; $wpdb->delete($db, array( 'id' => $main_id ), array( '%d' )); } /** ************************************************************************ * REQUIRED. Set up a constructor that references the parent constructor. We * use the parent reference to set some default configs. ***************************************************************************/ function __construct() { global $status, $page; //Set parent defaults parent::__construct(array( 'singular' => 'main_id', //singular name of the listed records 'plural' => 'main_ids', //plural name of the listed records 'ajax' => false //does this table support ajax? )); } /** ************************************************************************ * Recommended. This method is called when the parent class can't find a method * specifically build for a given column. Generally, it's recommended to include * one method for each column you want to render, keeping your package class * neat and organized. For example, if the class needs to process a column * named 'title', it would first see if a method named $this->column_title() * exists - if it does, that method will be used. If it doesn't, this one will * be used. Generally, you should try to use custom column methods as much as * possible. * * Since we have defined a column_title() method later on, this method doesn't * need to concern itself with any column with a name of 'title'. Instead, it * needs to handle everything else. * * For more detailed insight into how columns are handled, take a look at * WP_List_Table::single_row_columns() * * @param array $item A singular item (one full row's worth of data) * @param array $column_name The name/slug of the column to be processed * @return string Text or HTML to be placed inside the column