Changeset 3636769
- Timestamp:
- 08/06/2026 02:55:33 PM (3 months ago)
- Location:
- affiliate-booster/trunk
- Files:
-
- 4 edited
-
affiliate-booster.php (modified) (4 diffs)
-
affiliate-classes.php (modified) (4 diffs)
-
affiliate-response.php (modified) (5 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
affiliate-booster/trunk/affiliate-booster.php
r2850536 r3636769 4 4 Plugin URI: https://wordpress.org/plugins/affiliate-booster/ 5 5 Description: WP Affiliate Link Manager add the links to your keywords based on the selection being made , making it easier to add the link to the keywords and generate the revenue via the affiliate marketing. 6 Version: 1.16 Version: 5.0.2 7 7 Author: Raj 8 8 Author URI: http://kbizsoft.com/ 9 9 */ 10 10 11 defined( 'ABSPATH') or die();11 defined('ABSPATH') or die(); 12 12 13 $abPlugin = plugin_basename(__FILE__); 13 $abPlugin = plugin_basename(__FILE__); 14 14 $afbtPath = plugin_dir_path(__FILE__); 15 $afbtPath .= '/affiliate-classes.php'; 15 $afbtPath .= '/affiliate-classes.php'; 16 16 include_once($afbtPath); 17 17 $afbtOpts = new AFBT_Options; 18 18 19 function affiliate_booster_install() { 19 function affiliate_booster_install() 20 { 20 21 global $wpdb; 21 22 $afbt_table_name1 = $wpdb->prefix . 'affiliate_boost'; … … 30 31 PRIMARY KEY (id) 31 32 )$charset_collate;"; 32 33 require_once( ABSPATH . 'wp-admin/includes/upgrade.php');34 35 dbDelta( $afbt_sql_table1);36 33 34 require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); 35 36 dbDelta($afbt_sql_table1); 37 37 38 $afbt_sql_table2 = "CREATE TABLE $afbt_table_name2 ( 38 39 w_id int(10) NOT NULL AUTO_INCREMENT, … … 42 43 PRIMARY KEY (w_id) 43 44 )$charset_collate;"; 44 dbDelta( $afbt_sql_table2);45 dbDelta($afbt_sql_table2); 45 46 } 46 47 47 register_activation_hook( __FILE__, 'affiliate_booster_install');48 48 register_activation_hook(__FILE__, 'affiliate_booster_install'); 49 49 50 /* 50 *51 *get the admin option page52 *53 */ 51 * 52 *get the admin option page 53 * 54 */ 54 55 55 56 if (is_admin()) { 56 add_action('admin_menu', array($afbtOpts, 'afbt_AddAdminPage'));57 } 57 add_action('admin_menu', array($afbtOpts, 'afbt_AddAdminPage')); 58 } 58 59 59 60 if (!is_admin()) { 60 61 add_filter('the_content', array($afbtOpts, 'afbt_replace_for_keywords'));61 62 add_filter('the_content', array($afbtOpts, 'afbt_replace_for_keywords')); 62 63 add_action('wp_footer', array($afbtOpts, 'afbt_frontscript')); 63 } 64 } 64 65 65 66 /* 66 * Remove db table after uninstall plugin 67 */ 68 function affiliate_booster_remove_database() { 67 * Remove db table after uninstall plugin 68 */ 69 function affiliate_booster_remove_database() 70 { 69 71 global $wpdb; 70 72 $afbt_table_name1 = $wpdb->prefix . 'affiliate_boost'; … … 74 76 $afbt_del_sql2 = "DROP TABLE IF EXISTS $afbt_table_name2"; 75 77 $wpdb->query($afbt_del_sql2); 76 } 77 register_deactivation_hook( __FILE__, 'affiliate_booster_remove_database');78 } 79 register_deactivation_hook(__FILE__, 'affiliate_booster_remove_database'); 78 80 -
affiliate-booster/trunk/affiliate-classes.php
r2850536 r3636769 1 1 <?php 2 2 3 defined( 'ABSPATH') or die();3 defined('ABSPATH') or die(); 4 4 5 5 class AFBT_Options 6 { 6 { 7 7 private $json_arr; 8 8 private $style; 9 9 private $linkarray; 10 public $wpdb; 11 public $table_name; 12 public $table_name2; 13 public $posts; 14 10 15 public function __construct() 11 16 { … … 16 21 $this->posts = $afbt_table_name3 = $this->wpdb->prefix . 'posts'; 17 22 } 18 19 public function afbt_AddAdminPage() 20 {21 $abOptionsPage = add_submenu_page('options-general.php','Affiliate Booster','Affiliate Booster','manage_options','affiliate-boost-options',array(&$this, 'afbtGetOptionsScreen'));22 $abStylePage = add_submenu_page('affiliate-boost-options','Style Editor','Style','manage_options','affiliate-boost-style',array(&$this, 'afbtGetOptionsScreen'));23 }24 25 public function afbtGetOptionsScreen() 26 {27 // Settings navigation tabs28 if( isset( $_GET[ 'tab' ]) || !isset($_GET['tab'])) {29 $active_tab = isset( $_GET[ 'tab' ] ) ? sanitize_text_field($_GET[ 'tab']) : 'affiliate_retrieval_section';30 }31 $afbtRetrieveLink = admin_url() . 'admin.php?page=affiliate-boost-options&tab=affiliate_retrieval_section';32 $afbtTestsLink= admin_url() . 'admin.php?page=affiliate-boost-options&tab=affiliate_style';33 34 echo '<h2 class="nav-tab-wrapper"><a href="' . esc_url($afbtRetrieveLink) .'" class="nav-tab ';35 echo $active_tab == 'affiliate_retrieval_section' ? 'nav-tab-active' : '';36 echo '">Affiliate Booster</a><a href="' . esc_url($afbtTestsLink) .'" class="nav-tab ';37 echo $active_tab == 'affiliate_style' ? 'nav-tab-active' : '';38 echo '">Style Editor</a></h2>';39 40 // Settings form41 if($_GET[ 'tab' ] == 'affiliate_retrieval_section' || !isset($_GET['tab'])){?>42 <div class="container">43 <div class="">23 24 public function afbt_AddAdminPage() 25 { 26 $abOptionsPage = add_submenu_page('options-general.php', 'Affiliate Booster', 'Affiliate Booster', 'manage_options', 'affiliate-boost-options', array(&$this, 'afbtGetOptionsScreen')); 27 $abStylePage = add_submenu_page('affiliate-boost-options', 'Style Editor', 'Style', 'manage_options', 'affiliate-boost-style', array(&$this, 'afbtGetOptionsScreen')); 28 } 29 30 public function afbtGetOptionsScreen() 31 { 32 // Settings navigation tabs 33 if (isset($_GET['tab']) || !isset($_GET['tab'])) { 34 $active_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'affiliate_retrieval_section'; 35 } 36 $afbtRetrieveLink = admin_url() . 'admin.php?page=affiliate-boost-options&tab=affiliate_retrieval_section'; 37 $afbtTestsLink = admin_url() . 'admin.php?page=affiliate-boost-options&tab=affiliate_style'; 38 39 echo '<h2 class="nav-tab-wrapper"><a href="' . esc_url($afbtRetrieveLink) . '" class="nav-tab '; 40 echo $active_tab == 'affiliate_retrieval_section' ? 'nav-tab-active' : ''; 41 echo '">Affiliate Booster</a><a href="' . esc_url($afbtTestsLink) . '" class="nav-tab '; 42 echo $active_tab == 'affiliate_style' ? 'nav-tab-active' : ''; 43 echo '">Style Editor</a></h2>'; 44 45 // Settings form 46 if (!isset($_GET['tab']) || $_GET['tab'] == 'affiliate_retrieval_section') { ?> 47 <div class="container"> 48 <div class=""> 44 49 <h1></h1> 45 50 <div class="col-sm-12"> 46 <table id="affiliate_grid" class="table table-condensed table-hover table-striped" width="60%" cellspacing="0" data-toggle="bootgrid"> 47 <div class="pull-left records-add"><button type="button" class="btn btn-xs btn-primary" id="command-add" data-row-id="0"> 48 <span class="glyphicon glyphicon-plus"></span><?php echo _e('Add Record','affiliate-booster') ; ?></button></div> 51 <table id="affiliate_grid" class="table table-condensed table-hover table-striped" width="60%" 52 cellspacing="0" data-toggle="bootgrid"> 53 <div class="pull-left records-add"><button type="button" class="btn btn-xs btn-primary" id="command-add" 54 data-row-id="0"> 55 <span 56 class="glyphicon glyphicon-plus"></span><?php echo _e('Add Record', 'affiliate-booster'); ?></button> 57 </div> 49 58 <thead> 50 59 <tr> 51 <th data-column-id="w_id" data-type="numeric" data-identifier="true"><?php echo _e('S.No.','affiliate-booster') ; ?></th> 52 <th data-column-id="website"><?php echo _e('Website Page Link','affiliate-booster') ; ?></th> 53 <th data-column-id="commands" data-formatter="commands" data-sortable="false"><?php echo _e('Action','affiliate-booster') ; ?></th> 60 <th data-column-id="w_id" data-type="numeric" data-identifier="true"> 61 <?php echo _e('S.No.', 'affiliate-booster'); ?> 62 </th> 63 <th data-column-id="website"><?php echo _e('Website Page Link', 'affiliate-booster'); ?></th> 64 <th data-column-id="commands" data-formatter="commands" data-sortable="false"> 65 <?php echo _e('Action', 'affiliate-booster'); ?> 66 </th> 54 67 </tr> 55 68 </thead> 56 69 </table> 57 70 </div> 58 </div>59 71 </div> 60 <div id="add_model" class="modal fade"> 61 <div class="modal-dialog"> 62 <div class="modal-content"> 63 <div class="modal-header"> 64 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 65 <h4 class="modal-title"><?php echo _e('Add Keyword','affiliate-booster') ; ?></h4> 66 </div> 67 <div class="modal-body"> 68 <form method="post" id="frm_add"> 69 <input type="hidden" value="add" name="actions" id="actions"> 70 <div class="form-group"> 71 <label for="page-type" class="control-label"><?php echo _e('Page Type','affiliate-booster') ; ?></label><br> 72 <label class="radio-inline"> 73 <input type="radio" name="type_page" id="page" value="page" class="radio" checked><?php echo _e('Page','affiliate-booster') ; ?> 74 </label> 75 <label class="radio-inline"> 76 <input type="radio" name="type_page" id="post" value="post" class="radio"><?php echo _e('Post','affiliate-booster') ; ?> 77 </label> 72 </div> 73 <div id="add_model" class="modal fade"> 74 <div class="modal-dialog"> 75 <div class="modal-content"> 76 <div class="modal-header"> 77 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 78 <h4 class="modal-title"><?php echo _e('Add Keyword', 'affiliate-booster'); ?></h4> 79 </div> 80 <div class="modal-body"> 81 <form method="post" id="frm_add"> 82 <input type="hidden" value="add" name="actions" id="actions"> 83 <div class="form-group"> 84 <label for="page-type" 85 class="control-label"><?php echo _e('Page Type', 'affiliate-booster'); ?></label><br> 86 <label class="radio-inline"> 87 <input type="radio" name="type_page" id="page" value="page" class="radio" 88 checked><?php echo _e('Page', 'affiliate-booster'); ?> 89 </label> 90 <label class="radio-inline"> 91 <input type="radio" name="type_page" id="post" value="post" 92 class="radio"><?php echo _e('Post', 'affiliate-booster'); ?> 93 </label> 94 </div> 95 <div class="form-group"> 96 <label for="website-page-link" 97 class="control-label"><?php echo _e('Website Page Link:', 'affiliate-booster'); ?></label> 98 <select id="selectBox" name="add_website" style="width:100%"> 99 <option value=""><?php echo _e('Select Option', 'affiliate-booster'); ?></option> 100 </select><br><br> 101 <!--<input type="text" class="form-control" id="website" name="add_website"/>--> 102 </div> 103 <label for="keywords" 104 class="control-label"><?php echo _e('Keywords & Affiliate Link:', 'affiliate-booster'); ?></label><br> 105 <div class="form-group input_fields_wrap"> 106 <div class="ddd"> 107 108 <input type="text" id="keywords_1" class="keywords" placeholder="Keyword: 1" 109 name="keywords[]" /> 110 111 <input type="text" id="affiliate_link_1" class="affiliate_link" 112 placeholder="http:// or https://" name="affiliate_link[]" /> 113 114 <button 115 class="btn add_field_button btn-primary"><?php echo _e('Add More Fields', 'affiliate-booster'); ?></button> 78 116 </div> 79 <div class="form-group"> 80 <label for="website-page-link" class="control-label"><?php echo _e('Website Page Link:','affiliate-booster') ; ?></label> 81 <select id="selectBox" name="add_website" style="width:100%"> 82 <option value=""><?php echo _e('Select Option','affiliate-booster') ; ?></option> 83 </select><br><br> 84 <!--<input type="text" class="form-control" id="website" name="add_website"/>--> 85 </div> 86 <label for="keywords" class="control-label"><?php echo _e('Keywords & Affiliate Link:','affiliate-booster') ; ?></label><br> 87 <div class="form-group input_fields_wrap"> 88 <div class="ddd"> 89 90 <input type="text" id="keywords_1" class="keywords" placeholder="Keyword: 1" name="keywords[]"/> 91 92 <input type="text" id="affiliate_link_1" class="affiliate_link" placeholder="http:// or https://" name="affiliate_link[]"/> 93 94 <button class="btn add_field_button btn-primary"><?php echo _e('Add More Fields','affiliate-booster') ; ?></button> 95 </div> 96 <div class="input_fields_wraps"></div> 97 </div> 98 <div class="modal-footer"> 99 <button type="button" class="btn btn-default close_btn " data-dismiss="modal"><?php echo _e('Close','affiliate-booster') ; ?></button> 100 <button type="button" id="btn_add" class="btn btn-primary"><?php echo _e('Save','affiliate-booster') ; ?></button> 101 </div> 102 </form> 103 </div> 117 <div class="input_fields_wraps"></div> 118 </div> 119 <div class="modal-footer"> 120 <button type="button" class="btn btn-default close_btn " 121 data-dismiss="modal"><?php echo _e('Close', 'affiliate-booster'); ?></button> 122 <button type="button" id="btn_add" 123 class="btn btn-primary"><?php echo _e('Save', 'affiliate-booster'); ?></button> 124 </div> 125 </form> 104 126 </div> 105 127 </div> 106 128 </div> 107 <div id="edit_model" class="modal fade"> 108 <div class="modal-dialog"> 109 <div class="modal-content"> 110 <div class="modal-header"> 111 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 112 <h4 class="modal-title"><?php echo _e('Edit Keywords','affiliate-booster') ; ?></h4> 113 </div> 114 <div class="modal-body"> 115 <form method="post" id="frm_edit"> 116 <input type="hidden" value="edit" name="actions" id="actions"> 117 <input type="hidden" value="0" name="edit_id" id="edit_id"> 118 <div class="form-group"> 119 <label for="page-type" class="control-label"><?php echo _e('Page Type','affiliate-booster') ; ?></label><br> 120 <label class="radio-inline"> 121 <input type="radio" name="type_page_edit" id="page_edit" value="page" class="radio_edit" checked><?php echo _e('Page','affiliate-booster') ; ?> 122 </label> 123 <label class="radio-inline"> 124 <input type="radio" name="type_page_edit" id="post_edit" value="post" class="radio_edit"><?php echo _e('Post','affiliate-booster') ; ?> 125 </label> 126 </div> 127 <div class="form-group"> 128 <label for="website-page-link" class="control-label"><?php echo _e('Website Page Link:','affiliate-booster') ; ?></label> 129 <select id="edit_website" name="edit_website" style="width:100%"></select> 130 </div> 131 <div class="form-group"> 132 <button class="btn add_field_edit btn-primary"><?php echo _e('Add More Fields','affiliate-booster') ; ?></button> 133 </div> 134 <label for="keywords" class="control-label"><?php echo _e('Keywords & Affiliate Link:','affiliate-booster') ; ?></label><br> 135 <div class="form-group input_fields_edit" id="form-group"></div> 136 <div class="modal-footer"> 137 <button type="button" class="btn btn-default close_btn" data-dismiss="modal"><?php echo _e('Close','affiliate-booster') ; ?></button> 138 <button type="button" id="btn_edit" class="btn btn-primary"><?php echo _e('Save','affiliate-booster') ; ?></button> 139 </div> 140 </form> 141 </div> 129 </div> 130 <div id="edit_model" class="modal fade"> 131 <div class="modal-dialog"> 132 <div class="modal-content"> 133 <div class="modal-header"> 134 <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> 135 <h4 class="modal-title"><?php echo _e('Edit Keywords', 'affiliate-booster'); ?></h4> 136 </div> 137 <div class="modal-body"> 138 <form method="post" id="frm_edit"> 139 <input type="hidden" value="edit" name="actions" id="actions"> 140 <input type="hidden" value="0" name="edit_id" id="edit_id"> 141 <div class="form-group"> 142 <label for="page-type" 143 class="control-label"><?php echo _e('Page Type', 'affiliate-booster'); ?></label><br> 144 <label class="radio-inline"> 145 <input type="radio" name="type_page_edit" id="page_edit" value="page" class="radio_edit" 146 checked><?php echo _e('Page', 'affiliate-booster'); ?> 147 </label> 148 <label class="radio-inline"> 149 <input type="radio" name="type_page_edit" id="post_edit" value="post" 150 class="radio_edit"><?php echo _e('Post', 'affiliate-booster'); ?> 151 </label> 152 </div> 153 <div class="form-group"> 154 <label for="website-page-link" 155 class="control-label"><?php echo _e('Website Page Link:', 'affiliate-booster'); ?></label> 156 <select id="edit_website" name="edit_website" style="width:100%"></select> 157 </div> 158 <div class="form-group"> 159 <button 160 class="btn add_field_edit btn-primary"><?php echo _e('Add More Fields', 'affiliate-booster'); ?></button> 161 </div> 162 <label for="keywords" 163 class="control-label"><?php echo _e('Keywords & Affiliate Link:', 'affiliate-booster'); ?></label><br> 164 <div class="form-group input_fields_edit" id="form-group"></div> 165 <div class="modal-footer"> 166 <button type="button" class="btn btn-default close_btn" 167 data-dismiss="modal"><?php echo _e('Close', 'affiliate-booster'); ?></button> 168 <button type="button" id="btn_edit" 169 class="btn btn-primary"><?php echo _e('Save', 'affiliate-booster'); ?></button> 170 </div> 171 </form> 142 172 </div> 143 173 </div> 144 </div> 174 </div> 175 </div> 145 176 <script type="text/javascript"> 146 jQuery.noConflict(); 147 jQuery( document ).ready(function(jQuey) { 148 var grid = jQuery("#affiliate_grid").bootgrid({ 149 ajax: true, 150 rowSelect: true, 151 url: "<?php echo admin_url("admin-ajax.php?action=afbt_db_function", null); ?>", 152 formatters: { 153 "commands": function(column, row) 154 { 155 return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.web_id + "\"><span class=\"glyphicon glyphicon-edit\"></span></button> " + 156 "<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.web_id + "\"><span class=\"glyphicon glyphicon-trash\"></span></button>"; 157 } 177 jQuery.noConflict(); 178 jQuery(document).ready(function (jQuey) { 179 var grid = jQuery("#affiliate_grid").bootgrid({ 180 ajax: true, 181 rowSelect: true, 182 url: "<?php echo admin_url("admin-ajax.php?action=afbt_db_function", null); ?>", 183 formatters: { 184 "commands": function (column, row) { 185 return "<button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.web_id + "\"><span class=\"glyphicon glyphicon-edit\"></span></button> " + 186 "<button type=\"button\" class=\"btn btn-xs btn-default command-delete\" data-row-id=\"" + row.web_id + "\"><span class=\"glyphicon glyphicon-trash\"></span></button>"; 187 } 188 } 189 190 }).on("loaded.rs.jquery.bootgrid", function () { 191 /* Executes after data is loaded and rendered */ 192 grid.find(".command-edit").on("click", function (e) { 193 var ele = jQuery(this).parent(); 194 jQuery("#edit_model").modal("show"); 195 if (jQuery(this).data("row-id") > 0) { 196 // collect the data 197 var id = jQuery(this).data("row-id"); 198 jQuery("#edit_id").val(jQuery(this).data("row-id")); 199 jQuery("#form-group").html(""); 200 jQuery("#edit_website").html(""); 201 jQuery.ajax({ 202 type: "POST", 203 url: "<?php echo admin_url("admin-ajax.php", null); ?>", 204 data: { action: "afbt_db_function", 'actions': 'edit_all', 'id': id }, 205 success: function (response) { 206 var split_res = response.split('++'); 207 jQuery("input[name=type_page_edit][value='" + jQuery.trim(split_res[2]) + "']").prop("checked", true); 208 jQuery("#form-group").append(split_res[0]); 209 jQuery("#edit_website").append(split_res[1]); 210 } 211 }); 212 } else { 213 alert("Now row selected! First select row, then click edit button"); 214 } 215 }).end().find(".command-delete").on("click", function (e) { 216 217 var conf = confirm("Are you sure want to delete"); 218 if (conf) { 219 jQuery.post("<?php echo admin_url("admin-ajax.php", null); ?>", { id: jQuery(this).data("row-id"), action: "afbt_db_function", actions: "delete" } 220 , function () { 221 jQuery("#affiliate_grid").bootgrid("reload"); 222 }); 223 } 224 }); 225 }); 226 /* 227 * 228 */ 229 function addError(current_id, err_class) { // show error on add blank fields 230 jQuery("#" + current_id).css("border", "2px solid red"); 231 jQuery("#" + current_id).addClass(err_class); 158 232 } 159 160 }).on("loaded.rs.jquery.bootgrid", function(){ 161 /* Executes after data is loaded and rendered */ 162 grid.find(".command-edit").on("click", function(e){ 163 var ele =jQuery(this).parent(); 164 jQuery("#edit_model").modal("show"); 165 if(jQuery(this).data("row-id") >0) { 166 // collect the data 167 var id = jQuery(this).data("row-id"); 168 jQuery("#edit_id").val(jQuery(this).data("row-id")); 169 jQuery("#form-group").html(""); 170 jQuery("#edit_website").html(""); 171 jQuery.ajax({ 172 type: "POST", 173 url: "<?php echo admin_url("admin-ajax.php", null); ?>", 174 data: { action: "afbt_db_function", 'actions':'edit_all','id': id}, 175 success: function(response){ 176 var split_res = response.split('++'); 177 jQuery("input[name=type_page_edit][value='"+jQuery.trim(split_res[2])+"']").prop("checked",true); 178 jQuery("#form-group").append(split_res[0]); 179 jQuery("#edit_website").append(split_res[1]); 180 } 233 function removeError(current_id, err_class) { // show error on edit blank fields 234 jQuery("#" + current_id).css("border", "1px solid #ddd"); 235 jQuery("#" + current_id).removeClass(err_class); 236 } 237 jQuery(document).on("change", ".keywords", function (event) { 238 var key = jQuery(this).val().trim(); 239 var current_id = jQuery(this).attr("id"); 240 var website_val = jQuery("select[name=add_website]").val(); 241 if (website_val) { 242 removeError("selectBox", "error_ab"); 243 jQuery('.keywords').each(function () { 244 var loop_id = jQuery(this).attr("id"); 245 var old_key = jQuery(this).val().trim(); 246 if (current_id == loop_id) { 247 if (!jQuery(".error_ab").is(":visible")) { 248 jQuery.ajax({ 249 type: "POST", 250 url: "<?php echo admin_url("admin-ajax.php", null); ?>", 251 data: { action: 'afbt_db_function', actions: "get_match", 'page_val': website_val, 'value': key }, 252 success: function (response) { 253 var res = response.trim(); 254 if (res == 'Exists') { 255 addError(current_id, 'error_ab'); 256 jQuery("#" + current_id).css("border", "2px solid red"); 257 alert("Keyword " + key + " Allready Exist In Database"); 258 jQuery("#" + current_id).val(""); 259 } else { 260 removeError(current_id, "error_ab"); 261 } 262 } 263 }) 264 } 265 } else { 266 if (key == old_key) { 267 addError(current_id, 'error_ab'); 268 alert("Keyword " + key + " Allready Exist"); 269 jQuery("#" + current_id).val(""); 270 } else { 271 removeError(loop_id, "error_ab"); 272 } 273 } 181 274 }); 182 275 } else { 183 alert("Now row selected! First select row, then click edit button"); 184 } 185 }).end().find(".command-delete").on("click", function(e){ 186 187 var conf = confirm("Are you sure want to delete"); 188 if(conf){ 189 jQuery.post("<?php echo admin_url("admin-ajax.php", null); ?>", { id: jQuery(this).data("row-id"), action:"afbt_db_function",actions:"delete"} 190 , function(){ 191 jQuery("#affiliate_grid").bootgrid("reload"); 192 }); 193 } 276 alert("Please Select Website Page Link"); 277 jQuery("#" + current_id).val(""); 278 addError("selectBox", "error_ab"); 279 } 280 }); 281 /* 282 * 283 */ 284 jQuery(document).on("change", ".keywords_edit", function (event) { 285 var key_edit = jQuery(this).val().trim();; 286 var currentedit_id = jQuery(this).attr("id"); 287 jQuery('.keywords_edit').each(function () { 288 var loopedit_id = jQuery(this).attr("id"); 289 var oldedit_key = jQuery(this).val().trim();; 290 291 if (currentedit_id == loopedit_id) { 292 removeError(loopedit_id, "error_edit"); 293 } 294 else { 295 296 if (key_edit == oldedit_key) { 297 addError(currentedit_id, "error_edit"); 298 alert("Keyword " + key_edit + " Allready Exist"); 299 jQuery("#" + currentedit_id).val(""); 300 } else { 301 removeError(loopedit_id, "error_edit"); 302 } 303 } 304 305 }); 306 }); 307 // validate fileds 308 function validate_field(field_n) { 309 if (field_n == "input[name='keywords[]']" || field_n == "input[name='affiliate_link[]']") { 310 var err_cls = 'error_ab'; 311 } else { 312 var err_cls = 'error_edit'; 313 } 314 jQuery(field_n).each(function () { 315 var value = jQuery(this).val(); 316 var id = jQuery(this).attr("id"); 317 if (value.length === 0) { 318 jQuery("#" + id).css("border", "2px solid red"); 319 jQuery("#" + id).addClass(err_cls); 320 } else { 321 jQuery("#" + id).removeClass(err_cls); 322 jQuery("#" + id).css("border", "1px solid #ddd"); 323 } 324 }); 325 } 326 // save fileds 327 function ajaxAction(action) { 328 data = jQuery("#frm_" + action).serializeArray(); 329 jQuery.ajax({ 330 type: "POST", 331 url: "<?php echo admin_url("admin-ajax.php?action=afbt_db_function", null); ?>", 332 data: data, 333 dataType: "json", 334 success: function (response) { 335 jQuery("#" + action + "_model").modal("hide"); 336 jQuery("#affiliate_grid").bootgrid("reload"); 337 } 338 }); 339 } 340 341 jQuery(".close_btn").click(function () { 342 jQuery("#affiliate_grid").bootgrid("reload"); 343 }); 344 345 jQuery("#command-add").click(function () { 346 jQuery(".input_fields_wraps").html(""); 347 jQuery('#frm_add input[type="text"]').val(''); 348 jQuery("#add_model").modal("show"); 349 var page_type = jQuery('input[name=type_page]:checked').val(); 350 jQuery.ajax({ 351 type: "POST", 352 url: "<?php echo admin_url("admin-ajax.php", null); ?>", 353 data: { action: 'afbt_db_function', actions: "get_posts", 'page_type': page_type }, 354 success: function (response) { 355 jQuery("#selectBox").html(""); 356 jQuery("#selectBox").append(response); 357 } 358 }); 359 }); 360 361 jQuery("#btn_add").click(function () { 362 var website_val = jQuery("select[name=add_website]").val(); 363 if (!website_val) { 364 addError("selectBox", "error_ab"); 365 false; 366 } else { 367 removeError("selectBox", "error_ab"); 368 } 369 370 validate_field("input[name='keywords[]']"); 371 validate_field("input[name='affiliate_link[]']"); 372 373 if (!jQuery("body").find(".error_ab").length) { 374 ajaxAction("add"); 375 } 376 }); 377 jQuery("#btn_edit").click(function () { 378 jQuery("#affiliate_grid").bootgrid("reload"); 379 380 var edit_website = jQuery("select[name=edit_website]").val(); 381 if (!edit_website) { 382 addError("edit_website", "error_edit"); 383 } else { 384 removeError("edit_website", "error_edit"); 385 } 386 validate_field("input[name='keywords_edit[]']"); 387 validate_field("input[name='affiliate_link_edit[]']"); 388 validate_field("input[name='keywords_edit_new[]']"); 389 validate_field("input[name='affiliate_link_edit_new[]']"); 390 391 if (!jQuery("body").find(".error_edit").length) { 392 ajaxAction("edit"); 393 } 394 }); 395 396 /* 397 * add extra keyword input to new records 398 */ 399 var max_fields = 60; //maximum input boxes allowed 400 var wrapper = jQuery(".input_fields_wraps"); //Fields wrapper 401 var add_button = jQuery(".add_field_button"); //Add button ID 402 403 var x = 1; //initlal text box count 404 jQuery(add_button).click(function (e) { //on add input button click 405 e.preventDefault(); 406 if (x < max_fields) { //max input box allowed 407 x++; //text box increment 408 jQuery(wrapper).append('<div><input type="text" id="keywords_' + x + '" class="keywords" placeholder="Keywords" name="keywords[]"/><br><input type="text" id="affiliate_link_' + x + '" placeholder="http:// or https://" class="affiliate_link" name="affiliate_link[]"/><a href="#" class="remove_field"><sapn class="remove_keywords">x</sapn></a></div>'); //add input box 409 410 } 411 }); 412 413 jQuery(wrapper).on("click", ".remove_field", function (e) { //user click on remove text 414 e.preventDefault(); var conf = confirm("Are you sure want to delete"); 415 if (conf) { 416 jQuery(this).parent('div').remove(); 417 } 418 419 }) 420 /* 421 * add more filed to edit form 422 */ 423 var add_field_edit = jQuery(".add_field_edit"); //Add button ID 424 var input_fields_edit = jQuery(".input_fields_edit"); 425 var max_fields = 60; 426 427 jQuery(add_field_edit).click(function (e) { 428 e.preventDefault(); 429 var y = jQuery('#form-group .keywords_edit').length; 430 if (y < max_fields) { 431 y++; 432 jQuery(input_fields_edit).append('<div><input type="hidden" value="" name="keys_id[]" class="keys_id"><input type="text" id="edit_keywords_' + y + '" placeholder="keywords" class="keywords_edit" value="" name="keywords_edit_new[]"/><br><input type="text" id="edit_affiliate_link_' + y + '" value="" class="affiliate_link" name="affiliate_link_edit_new[]" placeholder="http:// or https://" /><a href="#" class="remove_field_edit"><sapn class="remove_keywords">x</sapn></a></div>'); 433 } 434 }); 435 jQuery(".input_fields_edit").on("click", ".remove_field_edit", function (e) { //user click on remove text 436 e.preventDefault(); var conf = confirm("Are you sure want to delete"); 437 var get_id = jQuery(this).attr("id"); 438 if (conf) { 439 jQuery(this).parent('div').remove(); 440 jQuery.post("<?php echo admin_url("admin-ajax.php", null); ?>", { key_id: get_id, action: "afbt_db_function", actions: "delete" } 441 , function () { 442 443 }); 444 } 445 446 }) 447 /* 448 * get the post type 449 */ 450 jQuery(".radio").click(function () { 451 var page_type = jQuery('input[name=type_page]:checked').val(); 452 jQuery.ajax({ 453 type: "POST", 454 url: "<?php echo admin_url("admin-ajax.php", null); ?>", 455 data: { 'page_type': page_type, action: "afbt_db_function", actions: "get_posts" }, 456 success: function (response) { 457 jQuery("#selectBox").html(""); 458 jQuery("#selectBox").append(response); 459 } 460 }); 461 }); 462 jQuery(".radio_edit").click(function () { 463 var page_type = jQuery(this).val(); 464 jQuery.ajax({ 465 type: "POST", 466 url: "<?php echo admin_url("admin-ajax.php", null); ?>", 467 data: { 'page_type': page_type, action: "afbt_db_function", actions: "get_posts" }, 468 success: function (response) { 469 jQuery("#edit_website").html(""); 470 jQuery("#edit_website").append(response); 471 } 472 }); 194 473 }); 195 474 }); 196 /*197 *198 */199 function addError(current_id,err_class){ // show error on add blank fields200 jQuery("#"+current_id).css("border", "2px solid red");201 jQuery("#"+current_id).addClass(err_class);202 }203 function removeError(current_id,err_class){ // show error on edit blank fields204 jQuery("#"+current_id).css("border", "1px solid #ddd");205 jQuery("#"+current_id).removeClass(err_class);206 }207 jQuery(document).on("change",".keywords",function(event) {208 var key = jQuery(this).val().trim();209 var current_id = jQuery(this).attr("id");210 var website_val= jQuery("select[name=add_website]").val();211 if(website_val){212 removeError("selectBox","error_ab");213 jQuery('.keywords').each(function(){214 var loop_id = jQuery(this).attr("id");215 var old_key = jQuery(this).val().trim();216 if(current_id == loop_id){217 if(!jQuery(".error_ab").is(":visible")){218 jQuery.ajax({219 type: "POST",220 url: "<?php echo admin_url("admin-ajax.php", null); ?>",221 data: { action:'afbt_db_function',actions:"get_match",'page_val': website_val,'value':key},222 success: function(response){223 var res = response.trim();224 if(res == 'Exists'){225 addError(current_id,'error_ab');226 jQuery("#"+current_id).css("border", "2px solid red");227 alert("Keyword "+key+" Allready Exist In Database");228 jQuery("#"+current_id).val("");229 }else{230 removeError(current_id,"error_ab");231 }232 }233 })234 }235 }else{236 if(key == old_key){237 addError(current_id,'error_ab');238 alert("Keyword "+key+" Allready Exist");239 jQuery("#"+current_id).val("");240 }else{241 removeError(loop_id,"error_ab");242 }243 }244 });245 }else{246 alert("Please Select Website Page Link");247 jQuery("#"+current_id).val("");248 addError("selectBox","error_ab");249 }250 });251 /*252 *253 */254 jQuery(document).on("change",".keywords_edit",function(event) {255 var key_edit = jQuery(this).val().trim();;256 var currentedit_id = jQuery(this).attr("id");257 jQuery('.keywords_edit').each(function(){258 var loopedit_id = jQuery(this).attr("id");259 var oldedit_key = jQuery(this).val().trim();;260 261 if(currentedit_id == loopedit_id){262 removeError(loopedit_id,"error_edit");263 }264 else{265 266 if(key_edit == oldedit_key){267 addError(currentedit_id,"error_edit");268 alert("Keyword "+key_edit+" Allready Exist");269 jQuery("#"+currentedit_id).val("");270 }else{271 removeError(loopedit_id,"error_edit");272 }273 }274 275 });276 });277 // validate fileds278 function validate_field(field_n){279 if(field_n == "input[name='keywords[]']" || field_n =="input[name='affiliate_link[]']"){280 var err_cls='error_ab';281 }else{282 var err_cls='error_edit';283 }284 jQuery(field_n).each(function() {285 var value = jQuery(this).val();286 var id = jQuery(this).attr("id");287 if (value.length === 0) {288 jQuery("#"+id).css("border", "2px solid red");289 jQuery("#"+id).addClass(err_cls);290 }else{291 jQuery("#"+id).removeClass(err_cls);292 jQuery("#"+id).css("border", "1px solid #ddd");293 }294 });295 }296 // save fileds297 function ajaxAction(action) {298 data = jQuery("#frm_"+action).serializeArray();299 jQuery.ajax({300 type: "POST",301 url: "<?php echo admin_url("admin-ajax.php?action=afbt_db_function", null); ?>",302 data: data,303 dataType: "json",304 success: function(response){305 jQuery("#"+action+"_model").modal("hide");306 jQuery("#affiliate_grid").bootgrid("reload");307 }308 });309 }310 311 jQuery( ".close_btn" ).click(function() {312 jQuery("#affiliate_grid").bootgrid("reload");313 });314 315 jQuery( "#command-add" ).click(function() {316 jQuery(".input_fields_wraps").html("");317 jQuery('#frm_add input[type="text"]').val('');318 jQuery("#add_model").modal("show");319 var page_type = jQuery('input[name=type_page]:checked').val();320 jQuery.ajax({321 type: "POST",322 url: "<?php echo admin_url("admin-ajax.php", null); ?>",323 data: { action:'afbt_db_function',actions:"get_posts",'page_type': page_type},324 success: function(response){325 jQuery("#selectBox").html("");326 jQuery("#selectBox").append(response);327 }328 });329 });330 331 jQuery( "#btn_add" ).click(function() {332 var website_val= jQuery("select[name=add_website]").val();333 if(!website_val){334 addError("selectBox","error_ab");335 false;336 }else{337 removeError("selectBox","error_ab");338 }339 340 validate_field("input[name='keywords[]']");341 validate_field("input[name='affiliate_link[]']");342 343 if(!jQuery("body").find(".error_ab").length){344 ajaxAction("add");345 }346 });347 jQuery( "#btn_edit" ).click(function() {348 jQuery("#affiliate_grid").bootgrid("reload");349 350 var edit_website= jQuery("select[name=edit_website]").val();351 if(!edit_website){352 addError("edit_website","error_edit");353 }else{354 removeError("edit_website","error_edit");355 }356 validate_field("input[name='keywords_edit[]']");357 validate_field("input[name='affiliate_link_edit[]']");358 validate_field("input[name='keywords_edit_new[]']");359 validate_field("input[name='affiliate_link_edit_new[]']");360 361 if(!jQuery("body").find(".error_edit").length){362 ajaxAction("edit");363 }364 });365 366 /*367 * add extra keyword input to new records368 */369 var max_fields = 60; //maximum input boxes allowed370 var wrapper = jQuery(".input_fields_wraps"); //Fields wrapper371 var add_button = jQuery(".add_field_button"); //Add button ID372 373 var x = 1; //initlal text box count374 jQuery(add_button).click(function(e){ //on add input button click375 e.preventDefault();376 if(x < max_fields){ //max input box allowed377 x++; //text box increment378 jQuery(wrapper).append('<div><input type="text" id="keywords_'+x+'" class="keywords" placeholder="Keywords" name="keywords[]"/><br><input type="text" id="affiliate_link_'+x+'" placeholder="http:// or https://" class="affiliate_link" name="affiliate_link[]"/><a href="#" class="remove_field"><sapn class="remove_keywords">x</sapn></a></div>'); //add input box379 380 }381 });382 383 jQuery(wrapper).on("click",".remove_field", function(e){ //user click on remove text384 e.preventDefault(); var conf = confirm("Are you sure want to delete");385 if(conf){386 jQuery(this).parent('div').remove();387 }388 389 })390 /*391 * add more filed to edit form392 */393 var add_field_edit = jQuery(".add_field_edit"); //Add button ID394 var input_fields_edit = jQuery(".input_fields_edit");395 var max_fields =60;396 397 jQuery(add_field_edit).click(function(e){398 e.preventDefault();399 var y = jQuery('#form-group .keywords_edit').length;400 if(y < max_fields){401 y++;402 jQuery(input_fields_edit).append('<div><input type="hidden" value="" name="keys_id[]" class="keys_id"><input type="text" id="edit_keywords_'+y+'" placeholder="keywords" class="keywords_edit" value="" name="keywords_edit_new[]"/><br><input type="text" id="edit_affiliate_link_'+y+'" value="" class="affiliate_link" name="affiliate_link_edit_new[]" placeholder="http:// or https://" /><a href="#" class="remove_field_edit"><sapn class="remove_keywords">x</sapn></a></div>');403 }404 });405 jQuery(".input_fields_edit").on("click",".remove_field_edit", function(e){ //user click on remove text406 e.preventDefault(); var conf = confirm("Are you sure want to delete");407 var get_id = jQuery(this).attr("id");408 if(conf){409 jQuery(this).parent('div').remove();410 jQuery.post("<?php echo admin_url("admin-ajax.php", null); ?>", { key_id: get_id, action:"afbt_db_function",actions:"delete"}411 , function(){412 413 });414 }415 416 })417 /*418 * get the post type419 */420 jQuery(".radio").click(function(){421 var page_type = jQuery('input[name=type_page]:checked').val();422 jQuery.ajax({423 type: "POST",424 url: "<?php echo admin_url("admin-ajax.php", null); ?>",425 data: { 'page_type': page_type,action:"afbt_db_function",actions:"get_posts"},426 success: function(response){427 jQuery("#selectBox").html("");428 jQuery("#selectBox").append(response);429 }430 });431 });432 jQuery(".radio_edit").click(function(){433 var page_type = jQuery(this).val();434 jQuery.ajax({435 type: "POST",436 url: "<?php echo admin_url("admin-ajax.php", null); ?>",437 data: { 'page_type': page_type,action:"afbt_db_function",actions:"get_posts"},438 success: function(response){439 jQuery("#edit_website").html("");440 jQuery("#edit_website").append(response);441 }442 });443 });444 });445 475 </script> 446 <?php447 }448 if ($_GET[ 'tab' ] == 'affiliate_style'){449 echo '<div class="wrap">476 <?php 477 } 478 if (isset($_GET['tab']) && $_GET['tab'] == 'affiliate_style') { 479 echo '<div class="wrap"> 450 480 <h2>Link Setting Options</h2> 451 481 <form method="post" action="options.php">'; 452 wp_nonce_field("update-options");?> 453 <table class="form-table"> 454 <tr valign="top"> 455 <th scope="row"><?php echo _e('Font Size','affiliate-booster') ; ?></th> 456 <td><input type="text" name="affiliate_boost_setting[font-size]" placeholder="10px" value="<?php get_option('affiliate_boost_setting')['font-size']?>" /></td> 457 </tr> 458 <tr valign="top"> 459 <th scope="row"><?php echo _e('Link Color','affiliate-booster') ; ?></th> 460 <td><input type="text" name="affiliate_boost_setting[font-color]" value="<?php get_option('affiliate_boost_setting')['font-color'] ?>" class="my-color-field"/></td> 461 </tr> 462 </table> 463 <p><input type="submit" class="btm button-primary" name="Submit" value="<?php echo _e('Save Options','affiliate-booster') ; ?>" /></p> 464 <input type="hidden" name="action" value="<?php echo _e('update','affiliate-booster') ; ?>" /> 465 <input type="hidden" name="page_options" value="<?php echo _e('affiliate_boost_setting','affiliate-booster') ; ?>" /> 466 <?php echo' 482 wp_nonce_field("update-options"); ?> 483 <table class="form-table"> 484 <tr valign="top"> 485 <th scope="row"><?php echo _e('Font Size', 'affiliate-booster'); ?></th> 486 <td><input type="text" name="affiliate_boost_setting[font-size]" placeholder="10px" 487 value="<?php get_option('affiliate_boost_setting')['font-size'] ?>" /></td> 488 </tr> 489 <tr valign="top"> 490 <th scope="row"><?php echo _e('Link Color', 'affiliate-booster'); ?></th> 491 <td><input type="text" name="affiliate_boost_setting[font-color]" 492 value="<?php get_option('affiliate_boost_setting')['font-color'] ?>" class="my-color-field" /></td> 493 </tr> 494 </table> 495 <p><input type="submit" class="btm button-primary" name="Submit" 496 value="<?php echo _e('Save Options', 'affiliate-booster'); ?>" /></p> 497 <input type="hidden" name="action" value="<?php echo _e('update', 'affiliate-booster'); ?>" /> 498 <input type="hidden" name="page_options" value="<?php echo _e('affiliate_boost_setting', 'affiliate-booster'); ?>" /> 499 <?php echo ' 467 500 </form> 468 501 </div>'; 469 }502 } 470 503 } 471 472 function array_intersect_fixed($array1, $array2) { 473 $result = array(); 474 foreach ($array1 as $val) { 475 if(!in_array($val['keywords'], $array2)){ 476 $results[] = $val ; 504 505 function array_intersect_fixed($array1, $array2) 506 { 507 $result = array(); 508 foreach ($array1 as $val) { 509 if (!in_array($val['keywords'], $array2)) { 510 $results[] = $val; 477 511 } 478 } 479 return $results; 480 } 512 } 513 return $results; 514 } 481 515 /* 482 * check the keywords in contents 483 */ 484 function afbt_replace_for_keywords( $content ) { 516 * check the keywords in contents 517 */ 518 function afbt_replace_for_keywords($content) 519 { 485 520 global $wp; 486 $current_page = home_url( $wp->request);521 $current_page = home_url($wp->request); 487 522 $page_title = get_the_title(); 488 523 $font_size = get_option('affiliate_boost_setting')['font-size']; 489 524 $font_color = get_option('affiliate_boost_setting')['font-color']; 490 525 491 if($font_color){ $style_color="color:".$font_color.";"; } 492 if(strpos($font_size, 'px') !== false){ $style_color.="font-size:".$font_size.";"; } 493 else{ if($font_size){ $style_color.="font-size:".$font_size."px;"; }} 494 495 $this->style = $style = "style='".$style_color."'"; 496 $qtot = $this->wpdb->get_results("SELECT keywords,affiliate_link FROM ".$this->table_name2." INNER JOIN ".$this->table_name." ON parent_id = w_id WHERE website = '".$page_title."'"); 497 $this->linkarray = $arrqtotay = json_decode( json_encode($qtot), true); 498 499 if($arrqtotay){ 500 foreach($arrqtotay as $getRecords){ 501 if(strpos($getRecords['keywords'], ',') !== false){ 502 $explode_keywords = explode(",",$getRecords['keywords']); 503 foreach($explode_keywords as $keywords){ 526 if ($font_color) { 527 $style_color = "color:" . $font_color . ";"; 528 } 529 if (strpos($font_size, 'px') !== false) { 530 $style_color .= "font-size:" . $font_size . ";"; 531 } else { 532 if ($font_size) { 533 $style_color .= "font-size:" . $font_size . "px;"; 534 } 535 } 536 537 $this->style = $style = "style='" . $style_color . "'"; 538 $qtot = $this->wpdb->get_results("SELECT keywords,affiliate_link FROM " . $this->table_name2 . " INNER JOIN " . $this->table_name . " ON parent_id = w_id WHERE website = '" . $page_title . "'"); 539 $this->linkarray = $arrqtotay = json_decode(json_encode($qtot), true); 540 541 if ($arrqtotay) { 542 foreach ($arrqtotay as $getRecords) { 543 if (strpos($getRecords['keywords'], ',') !== false) { 544 $explode_keywords = explode(",", $getRecords['keywords']); 545 foreach ($explode_keywords as $keywords) { 504 546 if (strpos($content, $keywords) !== false) { 505 $content = preg_replace("/\b" .$keywords."\b/", '<a class="afbt_link" '.$style. 'href="'.esc_url($getRecords['affiliate_link']).'">'.esc_html($keywords).'</a>',$content);547 $content = preg_replace("/\b" . $keywords . "\b/", '<a class="afbt_link" ' . $style . 'href="' . esc_url($getRecords['affiliate_link']) . '">' . esc_html($keywords) . '</a>', $content); 506 548 } 507 549 } 508 } else{550 } else { 509 551 if (strpos($content, $getRecords['keywords']) !== false) { 510 $content = preg_replace("/\b".$getRecords['keywords']."\b/", '<a class="afbt_link" '.$style. 'href="'.esc_url($getRecords['affiliate_link']).'">'.esc_html($getRecords['keywords']).'</a>',$content);511 552 $content = preg_replace("/\b" . $getRecords['keywords'] . "\b/", '<a class="afbt_link" ' . $style . 'href="' . esc_url($getRecords['affiliate_link']) . '">' . esc_html($getRecords['keywords']) . '</a>', $content); 553 512 554 } 513 555 } … … 515 557 libxml_use_internal_errors(true); 516 558 $dom = new DOMDocument; 517 $dom->loadHTML($content); 518 $array_link =array(); 519 foreach ($dom->getElementsByTagName('a') as $node){ 520 if($node->getattribute('class') == 'afbt_link') { 521 $array_link[] = trim($node->nodeValue); 522 } 523 } 559 560 if (empty(trim($content))) { 561 return $content; 562 } 563 564 $dom->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8')); 565 $array_link = array(); 566 foreach ($dom->getElementsByTagName('a') as $node) { 567 if ($node->getAttribute('class') == 'afbt_link') { 568 $array_link[] = trim($node->nodeValue); 569 } 570 } 524 571 $unique_arr = array_map("unserialize", array_unique(array_map("serialize", $array_link))); 525 $array_end = $this->array_intersect_fixed($arrqtotay, $unique_arr);572 $array_end = $this->array_intersect_fixed($arrqtotay, $unique_arr); 526 573 $this->json_arr = json_encode($array_end); 527 return $content;528 } else{529 return $content;574 return $content; 575 } else { 576 return $content; 530 577 } 531 578 } 532 533 function afbt_frontscript() { 579 580 function afbt_frontscript() 581 { 534 582 ?> 535 583 <script> 536 jQuery(document).ready(function(){ 537 var key_aff = <?php echo $this->json_arr ?>; 538 var key_aff_link = <?php echo json_encode($this->linkarray); ?>; 539 var key_css= "<?php echo $this->style ?>"; 540 jQuery.each(key_aff, function(idx, obj) { // get the json keywords 541 var names = [obj.keywords]; 542 var update_text = ''; 543 jQuery('.afbt_link').each(function(){ 544 var cntn = jQuery(this).text(); 545 var str_key = ""+names+""; 546 var str = str_key; 547 var re = new RegExp("\\b" + cntn + "\\b", "g"); 548 var matchk = str.match(re) ? str.match(re).length : 0; 549 550 if(matchk > 0){ // match the key in the content 551 var str_updaptes = document.getElementById("main").innerHTML; 552 var oldUrl = jQuery(this).attr("href"); 553 jQuery(this).text("ccc "+cntn); 554 jQuery(this).contents().unwrap(); 555 var str_updapte = document.getElementById("main").innerHTML; 556 var str_names = ''+names+''; 557 var key_names = str_names.replace(cntn,"ccc "+cntn); 558 var re = new RegExp("\\b" + key_names + "\\b", "g"); 559 var matchk_key = str_updapte.match(re) ? str_updapte.match(re).length : 0; 560 if(matchk_key > 0){ 561 update_text = str_updapte.replace(new RegExp(key_names, 'gi'), '<a '+key_css+' class="afbt_link" href="'+obj.affiliate_link+'">'+names+'</a>'); 562 563 }else{ 564 update_text = str_updapte.replace(new RegExp("ccc "+cntn, 'gi'), '<a '+key_css+' class="afbt_link" href="'+obj.affiliate_link+'">'+cntn+'</a>'); 565 } 584 jQuery(document).ready(function () { 585 var key_aff = <?php echo $this->json_arr ?>; 586 var key_aff_link = <?php echo json_encode($this->linkarray); ?>; 587 var key_css = "<?php echo $this->style ?>"; 588 jQuery.each(key_aff, function (idx, obj) { // get the json keywords 589 var names = [obj.keywords]; 590 var update_text = ''; 591 jQuery('.afbt_link').each(function () { 592 var cntn = jQuery(this).text(); 593 var str_key = "" + names + ""; 594 var str = str_key; 595 var re = new RegExp("\\b" + cntn + "\\b", "g"); 596 var matchk = str.match(re) ? str.match(re).length : 0; 597 598 if (matchk > 0) { // match the key in the content 599 var str_updaptes = document.getElementById("main").innerHTML; 600 var oldUrl = jQuery(this).attr("href"); 601 jQuery(this).text("ccc " + cntn); 602 jQuery(this).contents().unwrap(); 603 var str_updapte = document.getElementById("main").innerHTML; 604 var str_names = '' + names + ''; 605 var key_names = str_names.replace(cntn, "ccc " + cntn); 606 var re = new RegExp("\\b" + key_names + "\\b", "g"); 607 var matchk_key = str_updapte.match(re) ? str_updapte.match(re).length : 0; 608 if (matchk_key > 0) { 609 update_text = str_updapte.replace(new RegExp(key_names, 'gi'), '<a ' + key_css + ' class="afbt_link" href="' + obj.affiliate_link + '">' + names + '</a>'); 610 611 } else { 612 update_text = str_updapte.replace(new RegExp("ccc " + cntn, 'gi'), '<a ' + key_css + ' class="afbt_link" href="' + obj.affiliate_link + '">' + cntn + '</a>'); 613 } 614 } 615 }); 616 if (update_text) { 617 document.getElementById("main").innerHTML = update_text; 566 618 } 567 619 }); 568 if(update_text){ 569 document.getElementById("main").innerHTML = update_text; 570 } 620 621 jQuery.each(key_aff_link, function (idx, obj) { 622 var str = document.getElementById("main").innerHTML; 623 var names = [obj.keywords]; 624 updatenew = str.replace(new RegExp("ccc " + names, 'gi'), '<a ' + key_css + ' class="afbt_link" href="' + obj.affiliate_link + '">' + names + '</a>'); 625 document.getElementById("main").innerHTML = updatenew; 626 }); 627 var str_rep = document.getElementById("main").innerHTML; 628 update_rep = str_rep.replace(new RegExp("ccc", 'gi'), ''); 629 document.getElementById("main").innerHTML = update_rep; 571 630 }); 572 573 jQuery.each(key_aff_link, function(idx, obj) {574 var str = document.getElementById("main").innerHTML;575 var names = [obj.keywords];576 updatenew = str.replace(new RegExp("ccc "+names, 'gi'), '<a '+key_css+' class="afbt_link" href="'+obj.affiliate_link+'">'+names+'</a>');577 document.getElementById("main").innerHTML = updatenew;578 });579 var str_rep = document.getElementById("main").innerHTML;580 update_rep = str_rep.replace(new RegExp("ccc", 'gi'), '');581 document.getElementById("main").innerHTML = update_rep;582 });583 631 </script> 584 <?php }632 <?php } 585 633 } 586 634 587 635 // add js file to the admin 588 636 589 function afbt_admin_load_js($hook){ 590 if($hook != 'settings_page_affiliate-boost-options') { 637 function afbt_admin_load_js($hook) 638 { 639 if ($hook != 'settings_page_affiliate-boost-options') { 591 640 return; 592 641 } 593 wp_register_style('bootstrap_css', plugin_dir_url( __FILE__ ) . 'dist/bootstrap.min.css');594 wp_register_style('jquery_tablegrid', plugin_dir_url( __FILE__ ) . 'dist/jquery.tablegrid.css');595 wp_enqueue_script( 'bootstrap.min', plugin_dir_url( __FILE__ ) . 'dist/bootstrap.min.js', array( 'jquery' ));596 wp_enqueue_script( 'jquery.tablegrid', plugin_dir_url( __FILE__ ) . 'dist/jquery.tablegrid.min.js', array( 'jquery' ));597 wp_enqueue_script( 'custom', plugins_url('dist/custom.js', __FILE__ ), array( 'wp-color-picker' ), false, true);642 wp_register_style('bootstrap_css', plugin_dir_url(__FILE__) . 'dist/bootstrap.min.css'); 643 wp_register_style('jquery_tablegrid', plugin_dir_url(__FILE__) . 'dist/jquery.tablegrid.css'); 644 wp_enqueue_script('bootstrap.min', plugin_dir_url(__FILE__) . 'dist/bootstrap.min.js', array('jquery')); 645 wp_enqueue_script('jquery.tablegrid', plugin_dir_url(__FILE__) . 'dist/jquery.tablegrid.min.js', array('jquery')); 646 wp_enqueue_script('custom', plugins_url('dist/custom.js', __FILE__), array('wp-color-picker'), false, true); 598 647 wp_enqueue_script("jquery"); 599 648 wp_enqueue_style('bootstrap_css'); 600 649 wp_enqueue_style('jquery_tablegrid'); 601 wp_enqueue_style( 'wp-color-picker' );650 wp_enqueue_style('wp-color-picker'); 602 651 } 603 652 add_action('admin_enqueue_scripts', 'afbt_admin_load_js'); … … 609 658 add_action('wp_ajax_nopriv_afbt_db_function', 'afbt_db_function'); 610 659 611 function afbt_db_function() { 612 613 include_once(plugin_dir_path( __FILE__ ) . "affiliate-response.php"); 614 wp_die(); 660 function afbt_db_function() 661 { 662 663 include_once(plugin_dir_path(__FILE__) . "affiliate-response.php"); 664 wp_die(); 615 665 } -
affiliate-booster/trunk/affiliate-response.php
r1951406 r3636769 1 1 <?php 2 defined( 'ABSPATH') or die();2 defined('ABSPATH') or die(); 3 3 4 4 $params = $_REQUEST; // data array … … 7 7 $afbt_cls = new AFBT_Sql; 8 8 9 switch ($action) {9 switch ($action) { 10 10 case 'add': 11 11 $afbt_cls->afbt_insertKeywords($params); 12 12 break; 13 13 case 'edit': 14 $afbt_cls->afbt_updateKeywords($params); 14 $afbt_cls->afbt_updateKeywords($params); 15 15 break; 16 16 case 'delete': … … 25 25 case 'get_match': 26 26 $afbt_cls->afbt_get_match($params); 27 break; 27 break; 28 28 default: 29 29 $afbt_cls->afbt_getKeywords($params); 30 30 return; 31 31 } 32 33 class AFBT_Sql { 34 32 33 class AFBT_Sql 34 { 35 35 36 protected $data = array(); 36 37 public function afbt_getKeywords($params) { 37 38 public function afbt_getKeywords($params) 39 { 38 40 39 41 $this->data = $this->getRecords($params); 40 42 41 43 echo json_encode($this->data); 42 44 } 43 45 44 46 public function __construct() 45 47 { … … 50 52 $this->posts = $afbt_table_name3 = $this->wpdb->prefix . 'posts'; 51 53 } 52 53 function afbt_check_weblink($params,$type){ 54 55 function afbt_check_weblink($params, $type) 56 { 54 57 55 58 $params = sanitize_text_field($params); 56 $check_web = $this->wpdb->get_row("SELECT * from ".$this->table_name2." WHERE website='" .$params. "'");57 $check_webs = json_decode( json_encode($check_web), true);59 $check_web = $this->wpdb->get_row("SELECT * from " . $this->table_name2 . " WHERE website='" . $params . "'"); 60 $check_webs = json_decode(json_encode($check_web), true); 58 61 if (isset($check_webs)) { 59 62 $lastid = $check_webs['w_id']; 60 } else{61 $insert_web = $this->wpdb->query( $this->wpdb->prepare("INSERT INTO ".$this->table_name2." (w_id, post_type,website) VALUES(null, '".sanitize_text_field($type)."', '".$params."')"));62 $lastid = $this->wpdb->insert_id; 63 } else { 64 $insert_web = $this->wpdb->query($this->wpdb->prepare("INSERT INTO " . $this->table_name2 . " (w_id, post_type,website) VALUES(null, '" . sanitize_text_field($type) . "', '" . $params . "')")); 65 $lastid = $this->wpdb->insert_id; 63 66 } 64 67 return $lastid; 65 68 } 66 69 67 70 // Insert the new record 68 function afbt_insertKeywords($params) { 69 70 $lastid = $this->afbt_check_weblink($params["add_website"],$params["type_page"]); 71 72 if(!empty($lastid)){ 73 foreach($params["keywords"] as $key =>$key_link){ 74 $affl_link = preg_replace('/ /', '', $params["affiliate_link"][$key]); 75 $sql = $this->wpdb->query( $this->wpdb->prepare("INSERT INTO ".$this->table_name." (parent_id, keywords, affiliate_link) VALUES('" . sanitize_text_field($lastid) . "', '" . sanitize_text_field($key_link) . "','" . sanitize_text_field($affl_link) . "')")); 71 function afbt_insertKeywords($params) 72 { 73 74 $lastid = $this->afbt_check_weblink($params["add_website"], $params["type_page"]); 75 76 if (!empty($lastid)) { 77 foreach ($params["keywords"] as $key => $key_link) { 78 $affl_link = preg_replace('/ /', '', $params["affiliate_link"][$key]); 79 $sql = $this->wpdb->query($this->wpdb->prepare("INSERT INTO " . $this->table_name . " (parent_id, keywords, affiliate_link) VALUES('" . sanitize_text_field($lastid) . "', '" . sanitize_text_field($key_link) . "','" . sanitize_text_field($affl_link) . "')")); 76 80 echo $sql; 77 } 78 } 79 } 80 81 } 82 } 83 } 84 81 85 // Get the all records from the db 82 function getRecords($params) { 86 function getRecords($params) 87 { 83 88 84 89 $rp = isset($params['rowCount']) ? $params['rowCount'] : 10; 85 86 if (isset($params['current'])) { $page = $params['current']; } else { $page=1; }; 87 $start_from = ($page-1) * $rp; 88 90 91 if (isset($params['current'])) { 92 $page = $params['current']; 93 } else { 94 $page = 1; 95 } 96 ; 97 $start_from = ($page - 1) * $rp; 98 89 99 $insert_sql = $sqlRec = $sqlTotal = $where = ''; 90 91 if ( !empty($params['searchPhrase']) ) {92 $where .= " WHERE ";93 $where .= " ( website LIKE '".$params['searchPhrase']."%' )";94 }95 if( !empty($params['sort']) ) {96 $where .= " ORDER By ".key($params['sort']) .' '.current($params['sort'])." ";97 } 98 99 // getting total number records without any search100 101 $insert_sql = "SELECT * FROM " .$this->table_name2."";100 101 if (!empty($params['searchPhrase'])) { 102 $where .= " WHERE "; 103 $where .= " ( website LIKE '" . $params['searchPhrase'] . "%' )"; 104 } 105 if (!empty($params['sort'])) { 106 $where .= " ORDER By " . key($params['sort']) . ' ' . current($params['sort']) . " "; 107 } 108 109 // getting total number records without any search 110 111 $insert_sql = "SELECT * FROM " . $this->table_name2 . ""; 102 112 $sqlTotal .= $insert_sql; 103 113 $sqlRec .= $insert_sql; 104 114 105 115 //concatenate search sql if value exist 106 if (isset($where) && $where != '') {116 if (isset($where) && $where != '') { 107 117 $sqlTotal .= $where; 108 118 $sqlRec .= $where; 109 } else{119 } else { 110 120 $sqlRec .= ' ORDER By w_id DESC'; 111 121 } 112 113 if ($rp !=-1)114 $sqlRec .= " LIMIT ". $start_from .",".$rp;115 122 123 if ($rp != -1) 124 $sqlRec .= " LIMIT " . $start_from . "," . $rp; 125 116 126 $qtot = $this->wpdb->get_results($sqlTotal); 117 127 $queryRecords = $this->wpdb->get_results($sqlRec); 118 $count =1;119 120 if (!empty($queryRecords)){121 foreach ($queryRecords as $row){122 $array_count = '';123 $array_count = array("w_id" => $count);124 $rows = json_decode( json_encode($row), true);125 $title = "<sapn style='font-size:10px;' class='title_link'>(<a href=" .home_url(sanitize_title( $rows['website'] ))." target='_blank'>".home_url(sanitize_title( $rows['website'] ))."</a>)</span>";126 $new_rowarray= array('website'=>$rows['website']." ".$title,'web_id'=>$rows['w_id']);128 $count = 1; 129 130 if (!empty($queryRecords)) { 131 foreach ($queryRecords as $row) { 132 $array_count = ''; 133 $array_count = array("w_id" => $count); 134 $rows = json_decode(json_encode($row), true); 135 $title = "<sapn style='font-size:10px;' class='title_link'>(<a href=" . home_url(sanitize_title($rows['website'])) . " target='_blank'>" . home_url(sanitize_title($rows['website'])) . "</a>)</span>"; 136 $new_rowarray = array('website' => $rows['website'] . " " . $title, 'web_id' => $rows['w_id']); 127 137 $array_merge = array_merge($array_count, $new_rowarray); 128 138 $data[] = $array_merge; 129 139 $count++; 130 140 } 131 141 132 142 $json_data = array( 133 "current" => intval($params['current']),134 "rowCount" => 10,135 "total" => intval(count($qtot)),136 "rows" => $data // total data array137 );138 139 return $json_data;140 } 141 } 142 143 "current" => intval($params['current']), 144 "rowCount" => 10, 145 "total" => intval(count($qtot)), 146 "rows" => $data // total data array 147 ); 148 149 return $json_data; 150 } 151 } 152 143 153 // Update the record into db 144 function afbt_updateKeywords($params) { 145 146 $lastid = $this->afbt_check_weblink($params["edit_website"],$params["type_page_edit"]); // check the website url 147 148 if(!empty($lastid)){ 149 foreach($params["keys_id"] as $key_id=>$ids){ 154 function afbt_updateKeywords($params) 155 { 156 157 $lastid = $this->afbt_check_weblink($params["edit_website"], $params["type_page_edit"]); // check the website url 158 159 if (!empty($lastid)) { 160 foreach ($params["keys_id"] as $key_id => $ids) { 150 161 $affl_link = preg_replace('/ /', '', $params["affiliate_link_edit"][$key_id]); 151 $update_sql = $this->wpdb->query( $this->wpdb->prepare("Update ".$this->table_name." set parent_id = '" . $lastid . "', keywords='" .sanitize_text_field($params["keywords_edit"][$key_id])."', affiliate_link='" . sanitize_text_field($affl_link) . "' WHERE id='".$ids."'"));152 } 153 if (!empty($params["keywords_edit_new"])){154 foreach ($params["keywords_edit_new"] as $key =>$key_val){162 $update_sql = $this->wpdb->query($this->wpdb->prepare("Update " . $this->table_name . " set parent_id = '" . $lastid . "', keywords='" . sanitize_text_field($params["keywords_edit"][$key_id]) . "', affiliate_link='" . sanitize_text_field($affl_link) . "' WHERE id='" . $ids . "'")); 163 } 164 if (!empty($params["keywords_edit_new"])) { 165 foreach ($params["keywords_edit_new"] as $key => $key_val) { 155 166 $affl_linkn = preg_replace('/ /', '', $params["affiliate_link_edit_new"][$key]); 156 $update_sql = $this->wpdb->query( $this->wpdb->prepare("INSERT INTO ".$this->table_name." (parent_id, keywords, affiliate_link) VALUES('" .$lastid . "', '" . sanitize_text_field($key_val) . "','" . sanitize_text_field($affl_linkn) . "')"));167 $update_sql = $this->wpdb->query($this->wpdb->prepare("INSERT INTO " . $this->table_name . " (parent_id, keywords, affiliate_link) VALUES('" . $lastid . "', '" . sanitize_text_field($key_val) . "','" . sanitize_text_field($affl_linkn) . "')")); 157 168 } 158 169 } 159 echo $update_sql; 160 } 161 } 162 170 echo $update_sql; 171 } 172 } 173 163 174 // Delete record from tables 164 function afbt_deleteKeywords($params) { 165 166 if(!empty($params["key_id"])){ 167 $delete_sql = $this->wpdb->query( $this->wpdb->prepare("delete from ".$this->table_name." WHERE id='".$params["key_id"]."'")); 168 }else{ 169 $delete_sql = $this->wpdb->query( $this->wpdb->prepare("delete from ".$this->table_name." WHERE parent_id='".$params["id"]."'")); 170 $del_web_link= $this->wpdb->query( $this->wpdb->prepare("delete from ".$this->table_name2." WHERE w_id='".$params["id"]."'")); 171 } 172 173 174 175 function afbt_deleteKeywords($params) 176 { 177 178 if (!empty($params["key_id"])) { 179 $delete_sql = $this->wpdb->query($this->wpdb->prepare("delete from " . $this->table_name . " WHERE id='" . $params["key_id"] . "'")); 180 } else { 181 $delete_sql = $this->wpdb->query($this->wpdb->prepare("delete from " . $this->table_name . " WHERE parent_id='" . $params["id"] . "'")); 182 $del_web_link = $this->wpdb->query($this->wpdb->prepare("delete from " . $this->table_name2 . " WHERE w_id='" . $params["id"] . "'")); 183 } 184 185 186 175 187 echo $delete_sql; 176 188 } 177 189 178 190 // Edit records 179 function afbt_editKeywords($params) { 180 181 $query_weblink= $this->wpdb->get_results("SELECT * from ".$this->table_name2." WHERE w_id='" .$params['id'] . "'"); 182 $get_weblink = json_decode( json_encode($query_weblink), true); 183 184 $queryRecords = $this->wpdb->get_results("SELECT * from ".$this->table_name." WHERE parent_id='" .$params['id'] . "'"); 185 $check_webs = json_decode( json_encode($queryRecords), true); 186 187 $count=1; 188 189 $queryRecords_type = $this->wpdb->get_results("SELECT * from ".$this->posts." WHERE post_status='publish' AND post_type='" . $get_weblink[0]['post_type'] . "'"); 190 $check_records= json_decode( json_encode($queryRecords_type), true); 191 if(!empty($check_records)){ 192 $html_option='<option value="">Select Option</option>'; 193 foreach($check_records as $row){ 194 if($row['post_title'] == $get_weblink[0]['website']){ 195 $html_option.='<option value="'.$row['post_title'].'" selected="selected">'.$row['post_title'].'</option>'; 196 }else{ 197 $html_option.='<option value="'.$row['post_title'].'">'.$row['post_title'].'</option>'; 191 function afbt_editKeywords($params) 192 { 193 194 $query_weblink = $this->wpdb->get_results("SELECT * from " . $this->table_name2 . " WHERE w_id='" . $params['id'] . "'"); 195 $get_weblink = json_decode(json_encode($query_weblink), true); 196 197 $queryRecords = $this->wpdb->get_results("SELECT * from " . $this->table_name . " WHERE parent_id='" . $params['id'] . "'"); 198 $check_webs = json_decode(json_encode($queryRecords), true); 199 200 $count = 1; 201 202 $queryRecords_type = $this->wpdb->get_results("SELECT * from " . $this->posts . " WHERE post_status='publish' AND post_type='" . $get_weblink[0]['post_type'] . "'"); 203 $check_records = json_decode(json_encode($queryRecords_type), true); 204 if (!empty($check_records)) { 205 $html_option = '<option value="">Select Option</option>'; 206 foreach ($check_records as $row) { 207 if ($row['post_title'] == $get_weblink[0]['website']) { 208 $html_option .= '<option value="' . $row['post_title'] . '" selected="selected">' . $row['post_title'] . '</option>'; 209 } else { 210 $html_option .= '<option value="' . $row['post_title'] . '">' . $row['post_title'] . '</option>'; 198 211 } 199 200 } 201 } 202 $html ='';203 if (!empty($check_webs)){212 213 } 214 } 215 $html = ''; 216 if (!empty($check_webs)) { 204 217 $html = ''; 205 foreach ($check_webs as $row){206 $html .='<div><input type="hidden" value="'.$row['id'].'" name="keys_id[]" class="keys_id"><input type="text" id="edit_keywords_'.$count.'" class="keywords_edit" value="'.$row['keywords'].'" name="keywords_edit[]" placeholder="keywords: '.$count.'" /><br><input type="text" id="edit_affiliate_link_'.$count.'" value="'.$row['affiliate_link'].'" class="affiliate_link" name="affiliate_link_edit[]" placeholder="http:// or https://"/><a href="#" id="'.$row['id'].'" class="remove_field_edit"><sapn class="remove_keywords">x</sapn></a></div>';218 foreach ($check_webs as $row) { 219 $html .= '<div><input type="hidden" value="' . $row['id'] . '" name="keys_id[]" class="keys_id"><input type="text" id="edit_keywords_' . $count . '" class="keywords_edit" value="' . $row['keywords'] . '" name="keywords_edit[]" placeholder="keywords: ' . $count . '" /><br><input type="text" id="edit_affiliate_link_' . $count . '" value="' . $row['affiliate_link'] . '" class="affiliate_link" name="affiliate_link_edit[]" placeholder="http:// or https://"/><a href="#" id="' . $row['id'] . '" class="remove_field_edit"><sapn class="remove_keywords">x</sapn></a></div>'; 207 220 $count++; 208 221 } 209 echo $html ."++".$html_option."++".$get_weblink[0]['post_type'];210 } else{211 echo $html ."++".$html_option."++".$get_weblink[0]['post_type'];222 echo $html . "++" . $html_option . "++" . $get_weblink[0]['post_type']; 223 } else { 224 echo $html . "++" . $html_option . "++" . $get_weblink[0]['post_type']; 212 225 } 213 226 } 214 227 /* 215 * get the post type 216 */ 217 function afbt_get_post_pages($params){ 218 219 $queryRecords_type = $this->wpdb->get_results("SELECT * from ".$this->posts." WHERE post_status='publish' AND post_type='" .$params['page_type'] . "'"); 220 $get_post_page= json_decode( json_encode($queryRecords_type), true); 221 222 if(!empty($get_post_page)){ 223 $html='<option value="">Select Option</option>'; 224 foreach($get_post_page as $row){ 225 $html.='<option value="'.$row['post_title'].'">'.$row['post_title'].'</option>'; 228 * get the post type 229 */ 230 function afbt_get_post_pages($params) 231 { 232 233 $queryRecords_type = $this->wpdb->get_results("SELECT * from " . $this->posts . " WHERE post_status='publish' AND post_type='" . $params['page_type'] . "'"); 234 $get_post_page = json_decode(json_encode($queryRecords_type), true); 235 236 if (!empty($get_post_page)) { 237 $html = '<option value="">Select Option</option>'; 238 foreach ($get_post_page as $row) { 239 $html .= '<option value="' . $row['post_title'] . '">' . $row['post_title'] . '</option>'; 226 240 } 227 241 echo $html; 228 242 } 229 243 } 230 231 function afbt_get_match($params){ 232 $query_weblink= $this->wpdb->get_results("SELECT * from ".$this->table_name2." WHERE website='" .$params['page_val'] . "'"); 233 $get_weblink = json_decode( json_encode($query_weblink), true); 234 if($get_weblink){ 235 $query_weblink_check= $this->wpdb->get_results("SELECT keywords from ".$this->table_name." WHERE parent_id='" .$get_weblink[0]['w_id'] . "' AND keywords='".$params['value']."'"); 236 $get_weblink_check = json_decode( json_encode($query_weblink_check), true); 237 if($get_weblink_check){ 244 245 function afbt_get_match($params) 246 { 247 $query_weblink = $this->wpdb->get_results("SELECT * from " . $this->table_name2 . " WHERE website='" . $params['page_val'] . "'"); 248 $get_weblink = json_decode(json_encode($query_weblink), true); 249 if ($get_weblink) { 250 $query_weblink_check = $this->wpdb->get_results("SELECT keywords from " . $this->table_name . " WHERE parent_id='" . $get_weblink[0]['w_id'] . "' AND keywords='" . $params['value'] . "'"); 251 $get_weblink_check = json_decode(json_encode($query_weblink_check), true); 252 if ($get_weblink_check) { 238 253 echo "Exists"; 239 } else{254 } else { 240 255 echo "not exists"; 241 256 } 242 } else{257 } else { 243 258 echo "not exists"; 244 259 } … … 246 261 } 247 262 ?> 248 -
affiliate-booster/trunk/readme.txt
r3196502 r3636769 1 1 === WP Affiliate Link Manager === 2 2 Contributors: Raj 3 Tags: affiliate link manager, affiliate booster, affiliate marketing, affiliate marketing, linking keywords3 Tags: link manager, affiliate link manager, affiliate booster, affiliate marketing, affiliate marketing, linking keywords 4 4 Requires at least: 4.0 5 Tested up to: 6.6.1 6 Stable tag: 5.0.1 5 Tested up to: 7.0 6 Stable tag: 5.0.2 7 Requires PHP: 7.4 7 8 License: GPLv2 or later 8 9
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)