Changeset 3266493
- Timestamp:
- 04/03/2025 03:58:05 PM (12 months ago)
- Location:
- smm-api/trunk
- Files:
-
- 14 edited
-
assets/css/frontend.css (modified) (4 diffs)
-
assets/js/smm-script.js (modified) (8 diffs)
-
includes/admin/class.smapi-smm-api-items-list-table.php (modified) (7 diffs)
-
includes/admin/class.smapi-smm-servers-list-table.php (modified) (2 diffs)
-
includes/class.smapi-smm-ajax-call.php (modified) (4 diffs)
-
includes/class.smms-wc-api.php (modified) (2 diffs)
-
includes/class.smms-wc-subscription-admin.php (modified) (7 diffs)
-
includes/class.smms-wc-subscription-cart.php (modified) (1 diff)
-
includes/class.smms-wc-subscription-cron.php (modified) (6 diffs)
-
init.php (modified) (5 diffs)
-
plugin-fw/assets/css/smms-fields.css (modified) (1 diff)
-
plugin-fw/smm-plugin.php (modified) (1 diff)
-
plugin-options/privacy-options.php (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
smm-api/trunk/assets/css/frontend.css
r3166704 r3266493 202 202 .smm_form__field { 203 203 font-family: inherit; 204 width: 70%;205 border: 3px solid red;206 border-radius: 15px;207 border-bottom: 2px solid red;204 width: 90%; 205 border: 1px solid #c1baba; 206 207 border-bottom: 1px solid #d4cece; 208 208 outline: 0; 209 209 font-size: 0.9rem; 210 color: #4218eb;210 color: transparent; 211 211 padding: 1px 0; 212 background: transparent;212 background: #fbf8f800; 213 213 transition: border-color 0.2s; 214 214 … … 217 217 } 218 218 219 &:placeholder-shown ~.smm_form__label {220 font-size: 1.3rem;219 &:placeholder-shown.smm_form__label { 220 font-size: .9rem; 221 221 cursor: text; 222 top: 22px; 223 left: 12px; 222 position:relative; 223 top: -4px; 224 left: 10px; 225 color: transparent; 224 226 } 225 227 } … … 228 230 position: absolute; 229 231 z-index: -1; 230 top: -5px;232 top: 22px; 231 233 display: block; 232 234 transition: 0.2s; 233 font-size: 1rem;235 font-size: 0.9rem; 234 236 color: rgb(102, 0, 255); 235 237 } … … 238 240 ~.smm_form__label { 239 241 position: absolute; 240 top: - 5px;242 top: -9px; 241 243 display: block; 242 244 transition: 0.2s; 243 font-size: 1rem;245 font-size: 0.9rem; 244 246 color: #11998e; 245 font-weight: 700;246 } 247 248 padding-bottom: 6px;249 font-weight: 700;250 border-width: 3px;247 248 } 249 250 padding-bottom: 1px; 251 font-weight:1000; 252 border-width: 1px; 251 253 border-image: linear-gradient(to right, #11998e, #38ef7d); 252 254 border-image-slice: 1; -
smm-api/trunk/assets/js/smm-script.js
r3166704 r3266493 4 4 ajax("n_item_product", href[1]); 5 5 }); 6 6 7 7 8 jQuery("[id*=parameter_]").click(function(){ … … 10 11 jQuery(".server-display-table").fadeIn("fast"); 11 12 }); 13 jQuery("[id*=json_]").click(function(){ 14 var href = jQuery(this).attr("href").split("#"); 15 ajax("server_edit", href[1]); 16 17 jQuery(".server-entry-form").fadeIn("fast"); 18 19 }); 12 20 jQuery(".server-display-table").click(function(){ 13 21 jQuery(".server-display-table").fadeOut("fast"); … … 144 152 else if(action == "server_save"){ 145 153 data = jQuery("#server_info").serialize()+"&action="+action; 146 }154 } 147 155 else if(action == "server_delete"){ 148 156 data = "action="+action+"&item_id="+id; 149 }157 } 150 158 else if(action == "server_edit"){ 151 159 data = "action="+action+"&item_id="+id; 152 160 153 161 } 162 154 163 else if(action == "server_display"){ 155 164 data = "action="+action+"&item_id="+id; … … 197 206 { data: 'status' }, 198 207 { data: 'sub' }, 199 { data: 'view' } 208 { data: 'view' }, 209 { data: 'product' } 200 210 ], 201 211 columnDefs: [ { … … 301 311 } 302 312 else if(action == "server_edit"){ 303 313 var auto_price_enable = response.smm_price_update; 304 314 jQuery('input[name=fsid]').val(response.id); 305 315 jQuery('input[name=fapi_url]').val(response.api_url); … … 314 324 jQuery('input[name=fapi_status_order_handle]').val(response.api_status_order_handle); 315 325 jQuery('select[name=fapi_server_status]').val(response.api_server_status); 316 } 326 jQuery('select[name=fapi_price_update]').val(response.api_price_update); 327 if (auto_price_enable == "1") { 328 jQuery('#fsmm_price_update').prop("checked", true); 329 } else { 330 jQuery('#fsmm_price_update').prop("checked", false); 331 } 332 } 317 333 else if(action == "server_save"){ 318 334 SmmAdminNotice(response.notice, response.color); 319 jQuery(".server-entry-form").fadeOut("fast",function(){location.reload();}); 335 336 jQuery(".server-entry-form").fadeOut("fast",function(){}); 320 337 } 321 338 else if(action == "server_demo"){ … … 420 437 jQuery(document).on('change', 'select', function(){ 421 438 422 439 423 440 var smm_str = jQuery(this).attr('id'); 424 441 var itemspan = jQuery('option:selected', this).attr('data-desc'); … … 442 459 443 460 }); 461 jQuery(document).on('click', '[class^="smm_select"]', function(){ 462 463 jQuery(this).select2({width: 'resolve'}); 464 465 466 467 468 }); 444 469 445 470 }); -
smm-api/trunk/includes/admin/class.smapi-smm-api-items-list-table.php
r3172000 r3266493 1 1 <?php 2 3 2 if ( !defined( 'ABSPATH' ) || !defined( 'SMMS_SMAPI_VERSION' ) ) { 4 3 exit; // Exit if accessed directly … … 24 23 private $select_orderby; 25 24 private $select_order; 25 private $api_id_price = array(); 26 26 27 27 public function __construct( $args = array() ) { … … 42 42 function get_columns() { 43 43 $columns = array( 44 'cb' => '<input type="checkbox" />', 45 //'meta_id' => __( 'ID', 'smm-api' ), 46 'api_item_service_number'=> __( 'SERVICE ID', 'smm-api' ), 47 'api_item_description' => __( 'DESCRIPTION', 'smm-api' ), 48 'api_item_rate_per_1000' => __( 'RATE/1000', 'smm-api' ), 49 'api_item_min_order' => __( 'MIN', 'smm-api' ), 50 'api_item_max_order' => __( 'MAX', 'smm-api' ), 51 'api_item_status' => __( 'STATUS', 'smm-api' ), 52 'api_item_subscription' => __( 'SUBSCRIPTION', 'smm-api' ), 53 'api_item_display' => __( 'VIEW', 'smm-api' ), 44 'cb' => '<input type="checkbox" />', 45 //'meta_id' => __( 'ID', 'smm-api' ), 46 'api_item_service_number' => __( 'SERVICE ID', 'smm-api' ), 47 'api_item_description' => __( 'DESCRIPTION', 'smm-api' ), 48 'api_item_rate_per_1000' => __( 'RATE/1000', 'smm-api' ), 49 'api_item_min_order' => __( 'MIN', 'smm-api' ), 50 'api_item_max_order' => __( 'MAX', 'smm-api' ), 51 'api_item_status' => __( 'STATUS', 'smm-api' ), 52 'api_item_subscription' => __( 'SUBSCRIPTION', 'smm-api' ), 53 'api_item_display' => __( 'VIEW', 'smm-api' ), 54 'api_product_id' => __( 'PRODUCT ID', 'smm-api' ), 54 55 ); 55 56 return $columns; … … 138 139 139 140 $this->items = $smm_api_items; 140 141 $sm_api_ = array(); 142 //$smm_api_it = 143 foreach($smm_api_items as $sm_api_item){ 144 //foreach($sm_api_item as $sm_api_val) 145 $sm_api_= json_decode($sm_api_item->meta_value,true); 146 147 // arrypush will not give warning undefined key 148 array_push($this->api_id_price,[$sm_api_['f_service_id'] => $sm_api_['f_item_price']]); 149 } 150 // $this->api_id_price = serialize($sm_api_); 141 151 //echo serialize($this->items);// for testing 142 152 //echo serialize($this->api_servers); … … 146 156 $smm_api_items = json_decode($item->meta_value,true); 147 157 //new SMAPI_API_ITEM( $this->smm_api_server_item ); 148 158 149 159 switch( $column_name ) { 150 160 case 'meta_id': … … 194 204 return '<a href=#'.esc_attr($item->meta_key).' id="more_'.esc_attr($item->meta_key).'">More</a>'; 195 205 break; 206 case 'api_product_id': 207 //$api_product_id = $this->smm_api_products($item->meta_key); 208 $api_product_id = $this->smm_api_products($this->smm_api_server_item , $item->meta_key); 209 return esc_html($api_product_id); 210 break; 196 211 197 212 default: … … 199 214 } 200 215 } 201 216 /** 217 * Sets product idsd on api item . 218 * @param string $item_meta_key. Possible values: _item_. 219 * @return text 220 */ 221 // Get all products that use the api items 222 function smm_api_products($_server_id = '', $_item_val =''){ 223 224 //===========================product ids that has smm_api=========== 225 226 $args = array( 227 'post_type' => 'product', 228 'posts_per_page' => -1, // Get all matching products 229 'meta_key' => '_smapi_api', 230 'meta_value' => 'yes', 231 //'compare' => '=', 232 'fields' => 'ids', // Only retrieve product IDs 233 'meta_query' => array( 234 'key' => '_smapi_server_name_option',//one server 235 'value' => $_server_id, 236 'compare' => '=' 237 238 ) 239 ); 240 $argv = array( 241 'post_type' => 'product_variation', 242 'posts_per_page' => -1, // Get all matching products 243 'meta_key' => 'variable_smm_api', 244 'meta_value' => 'on', 245 'fields' => 'ids', // Only retrieve product IDs 246 'meta_query' => array( 247 'key' => 'var_smapi_server_name_option',//one server 248 'value' => $_server_id, 249 'compare' => '=' 250 251 ) 252 ); 253 254 $product_api = array(); 255 256 $simple_products_ids = get_posts( $args ); 257 foreach($simple_products_ids as $simple_products_id){ 258 if($_item_val == get_post_meta( $simple_products_id, '_smapi_service_id_option', true )) 259 array_push($product_api, 'S- '.$simple_products_id); 260 } 261 $variable_products_ids = get_posts( $argv ); 262 foreach($variable_products_ids as $variable_products_id){ 263 //Get first word from string strtok($value, " "); 264 265 if($_item_val == strtok( get_post_meta( $variable_products_id, 'var_smapi_service_id_option', true ), " ")) 266 { 267 $parent_id = wp_get_post_parent_id($variable_products_id); 268 array_push($product_api, 'V- '.$parent_id); 269 } 270 } 271 272 // Output product IDs 273 274 //=====================get id ends============= 275 $products_text = implode(', ', array_unique($product_api));//unique ids to string 276 $products_text = $products_text == '' ? 'NA' : $products_text; 277 return $products_text; 278 279 280 } 281 202 282 function get_bulk_actions( ) { 203 283 -
smm-api/trunk/includes/admin/class.smapi-smm-servers-list-table.php
r3166705 r3266493 138 138 case 'response_format': 139 139 $status = $item->post_excerpt; 140 return $status;140 return '<a href=#'.esc_attr($item->ID).' id="json_'.esc_attr($item->ID).'">'.$status.'</a>'; 141 141 break; 142 142 … … 281 281 <option value="disabled">DISABLED</option> 282 282 </select> 283 </td> 283 </td> 284 </tr> 285 <tr> 286 <td>Auto Price Update</td> 287 <td><select name="fapi_price_update"> 288 <option value="daily">Daily</option> 289 <option value="weekly">Weekly</option> 290 <option value="monthly">Monthly</option> 291 </select> 292 <input type="checkbox" name="fsmm_price_update" id="fsmm_price_update" /> 293 Enable 294 </td> 284 295 </tr> 285 296 <tr> -
smm-api/trunk/includes/class.smapi-smm-ajax-call.php
r3172000 r3266493 138 138 if( isset($_POST['fapi_status_order_handle'])) 139 139 $fapi_status_order_handle = sanitize_text_field($_POST['fapi_status_order_handle']); 140 140 if( isset($_POST['fapi_price_update'])) 141 $fapi_price_update = sanitize_text_field($_POST['fapi_price_update']); 141 142 if( isset($_POST['fapi_server_status'])) 142 143 $fapi_server_status = sanitize_text_field($_POST['fapi_server_status']); 144 $fsmm_price_update = isset($_POST['fsmm_price_update']) ? '1':'0'; 145 $_POST['fsmm_price_update'] = sanitize_text_field($fsmm_price_update); 143 146 if( isset($_POST['fsid'])) 144 147 $fsid = ( $_POST['fsid'] == '') ? NULL : sanitize_text_field($_POST['fsid']); … … 175 178 'api_status_order_handle' => $fapi_status_order_handle, 176 179 'enable_api' => $fapi_server_status, 180 'api_price_update' => $fapi_price_update,//auto price update shedule 181 'smm_price_update' => $fsmm_price_update,//checkbox enable 177 182 // Action parameter 178 'api_add_action' => 'add',179 'api_status_action' => 'status',180 'smapi_free_version' => SMMS_SMAPI_VERSION183 'api_add_action' => 'add', 184 'api_status_action' => 'status', 185 'smapi_free_version' => SMMS_SMAPI_VERSION 181 186 ); 182 187 $server = new SMAPI_Server( sanitize_text_field($_POST['fsid']), $args ); … … 298 303 //foreach($items as $item=>$value); 299 304 // response output 300 $response['success'] = 1;301 $response['action'] = 'server_edit';302 303 $response['id'] = $post_id;304 $response['api_url'] = $items[0]->post_title;305 $response['api_key_handle'] = $server_item['api_key_handle'];306 $response['api_key'] = $items[0]->post_content;307 $response['api_link_handle'] =$server_item['api_link_handle'];308 $response['api_service_handle'] = $server_item['api_service_handle'];309 $response['api_quantity_handle'] = $server_item['api_quantity_handle'];310 $response['api_order_response_handle'] =$server_item['api_order_response_handle'];311 $response['api_error_response_handle'] =$server_item['api_error_response_handle'];312 $response['api_retrieve_status_query'] =$server_item['api_retrieve_status_query'];313 $response['api_status_order_handle'] =$server_item['api_status_order_handle'];305 $response['success'] = 1; 306 $response['action'] = 'server_edit'; 307 308 $response['id'] = $post_id; 309 $response['api_url'] = $items[0]->post_title; 310 $response['api_key_handle'] = $server_item['api_key_handle']; 311 $response['api_key'] = $items[0]->post_content; 312 $response['api_link_handle'] = $server_item['api_link_handle']; 313 $response['api_service_handle'] = $server_item['api_service_handle']; 314 $response['api_quantity_handle'] = $server_item['api_quantity_handle']; 315 $response['api_order_response_handle'] = $server_item['api_order_response_handle']; 316 $response['api_error_response_handle'] = $server_item['api_error_response_handle']; 317 $response['api_retrieve_status_query'] = $server_item['api_retrieve_status_query']; 318 $response['api_status_order_handle'] = $server_item['api_status_order_handle']; 314 319 315 $response['api_server_status']= $items[0]->post_status; 320 $response['api_server_status'] = $items[0]->post_status; 321 $response['api_price_update'] = $server_item['api_price_update']; 322 $response['smm_price_update'] = $server_item['smm_price_update']; 316 323 echo wp_json_encode($response); 317 324 … … 552 559 $table_api_service[$key]->sub= "disabled"; 553 560 $table_api_service[$key]->view= 'As Item or Product'; 561 $table_api_service[$key]->product= 'Click Red Box & checkbox'; 554 562 } 555 563 $response['table_api_service'] = $table_api_service; -
smm-api/trunk/includes/class.smms-wc-api.php
r3174476 r3266493 137 137 138 138 $get_details_of_request = "server arg = ".esc_url($this->api_server_url)."?"." return data = ".esc_html(serialize($httpcode))."body data = "; 139 // file_put_contents(plugin_dir_path( __FILE__ )."check.txt", $get_details_of_request );139 140 140 if ( is_wp_error( $httpcode ) ) { 141 141 $error_message = wp_kses_post($httpcode->get_error_message()); … … 145 145 } 146 146 $result = wp_remote_retrieve_body( $httpcode ); 147 147 //file_put_contents(plugin_dir_path( __FILE__ )."check.php", $result ); 148 148 return $result; 149 149 } -
smm-api/trunk/includes/class.smms-wc-subscription-admin.php
r3174476 r3266493 184 184 185 185 } 186 wp_sprintf('186 printf(' 187 187 <label><input 188 188 type="checkbox" … … 196 196 197 197 /* translators: Help tip to explain why and when you should check the 'SMM API' type of product in WooCommerce */ 198 wc_help_tip( esc_html__( 'Enable this option if the product is a smm-api', 'smm-api') );198 echo(wc_help_tip( esc_html__( 'Enable this option if the product is a smm-api', 'smm-api' )) ); 199 199 200 200 echo '</label>'; … … 326 326 'label' => 'SMM API SERVICE ITEM', 327 327 'wrapper_class' => 'form-row form-row-first', 328 'class' => 's elect',328 'class' => 'smm_select_'.esc_attr( $loop ), 329 329 'description' => __( 'SMM SERVICE Item Loaded from SMM API ITEM LIST', 'smm-api' ), 330 330 'desc_tip' => true, … … 560 560 $api_item_list_options_output=''; 561 561 foreach($smm_api_items_listing as $sub_item_result){ 562 562 $smm_service_id = filter_var($sub_item_result['meta_key'], FILTER_SANITIZE_NUMBER_INT); 563 563 $descrption_opted_data = " Min Order: " .smms_decode_string($sub_item_result['meta_value'],'f_min_order'). 564 564 " Max Order: " .smms_decode_string($sub_item_result['meta_value'],'f_max_order') 565 .' Service ID - '. filter_var($sub_item_result['meta_key'], FILTER_SANITIZE_NUMBER_INT);565 .' Service ID - '.$smm_service_id; 566 566 567 567 $api_item_list_options_output .= '<option '; … … 580 580 ; 581 581 $api_item_list_options_output .= '>' 582 .esc_html( smms_decode_string($sub_item_result['meta_value'],'f_api_description'))583 // filter_var($sub_item_result['meta_key'], FILTER_SANITIZE_NUMBER_INT)582 .esc_html(' ID: '. $smm_service_id .' ' . smms_decode_string($sub_item_result['meta_value'],'f_api_description')) 583 //service id = filter_var($sub_item_result['meta_key'], FILTER_SANITIZE_NUMBER_INT) 584 584 . '</option>'; 585 585 } … … 613 613 <label for="_smapi_service_id"><?php esc_html_e( 'SMM API SERVICE', 'smm-api' ); ?></label> 614 614 615 <select id="_smapi_service_id_option" name="_smapi_service_id_option" class="s elect" style="margin-left: 3px;">615 <select id="_smapi_service_id_option" name="_smapi_service_id_option" class="smm_select" style="margin-left: 3px;"> 616 616 <?php 617 617 $allowed_html = array( … … 851 851 wp_enqueue_style( 'smms_smapi_datatables', SMMS_SMAPI_ASSETS_URL . '/css/datatables.css', SMMS_SMAPI_VERSION ); 852 852 wp_enqueue_style( 'smms_smapi_select_dataTables', SMMS_SMAPI_ASSETS_URL . '/css/select.dataTables.css', null, SMMS_SMAPI_VERSION ); 853 wp_enqueue_style( 'smms_select2css', '//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.css', false, '1.0', 'all' ); 854 wp_enqueue_script( 'smms_select2', '//cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js', array( 'jquery' ), '1.0', true ); 853 855 wp_enqueue_script( 'smms_smapi_admin', SMMS_SMAPI_ASSETS_URL . '/js/smapi-admin' . SMMS_SMAPI_SUFFIX . '.js', array( 'jquery' ), SMMS_SMAPI_VERSION, true ); 854 856 wp_enqueue_script( 'jquery-blockui', SMMS_SMAPI_ASSETS_URL . '/js/jquery.blockUI.min.js', array( 'jquery' ), '1.0', true ); -
smm-api/trunk/includes/class.smms-wc-subscription-cart.php
r3172360 r3266493 416 416 417 417 printf( 418 '<div class="var_smm_customer_input_field_label var_smm_customer_input_field_label-%1$d" >418 '<div class="var_smm_customer_input_field_label var_smm_customer_input_field_label-%1$d" style="margin-bottom:10px;"> 419 419 <label for="var_smm_customer_input_field_text" style="display:inline-block;">%2$s</label> 420 420 <input type="text" id="var_smm_customer_input_field_text_%3$d" name="var_smm_customer_input_field_text[]" value=""></div>', 421 421 esc_attr($variation_id), 422 esc_html( $var_smm_customer_input_field_label .' * : ' ,423 esc_attr($variation_id) )422 esc_html( $var_smm_customer_input_field_label .' * : ') , 423 esc_attr($variation_id) 424 424 ); 425 425 } -
smm-api/trunk/includes/class.smms-wc-subscription-cron.php
r3166705 r3266493 23 23 */ 24 24 protected static $instance; 25 25 // For cron shedule custom 26 public $minute = 60; 27 public $hourly = 3600; 28 Public $daily = 86400; 29 public $weekly = 604800; 30 public $monthly = 2628000; 31 32 public $smm_cron = array(); 33 public $smm_api_pro = array(); 34 public $smm_api_ids = array(); 26 35 /** 27 36 * Returns single instance of the class … … 47 56 */ 48 57 public function __construct() { 49 50 add_action( 'smapi_renew_cron', array( $this, 'set_cron' ), 30 ); 58 59 $smm_cron_set = json_decode(get_option('smm_cron'),true); 60 if(is_array($smm_cron_set))//Check any cron is set or not 61 $this->smm_cron = $smm_cron_set;//time str to arr 62 add_action( 'smapi_renew_cron', array( $this, 'set_cron' ), 30 ); 51 63 add_action( 'smapi_renew_orders', array( $this, 'renew_orders' ), 30 ); 64 add_action( 'smapi_price_update', array( $this, 'set_cron_price_update' ), 30 ); 65 add_action( 'smm_auto_price', array( $this, 'smm_auto_price_cron' ), 30 ); 66 //add_action( 'woocommerce_loaded', array( $this, 'smm_product_price_update' ), 30 ); 52 67 if (get_option( 'smapi_cron_job' ) == 'yes'){ 53 68 … … 58 73 smm_cron_deactivate(); 59 74 } 75 76 // check cron schedule enabled in privacy page 77 if (get_option( 'smapi_price_update' ) == 'yes'){ 78 79 if ( isset($this->smm_cron) && strtotime($this->smm_cron['smm_auto_price']) < time()){ 80 //update_option( 'active_cron_servers', gmdate( 'Y-m-d H:i:s',current_time('timestamp'))); 81 $ve = get_option( 'gmt_offset' ) > 0 ? '+' : '-'; 82 //$time_start = strtotime( '00:00 ' . $ve . get_option( 'gmt_offset' ) . ' HOURS' ); 83 if(strtotime($this->smm_cron['smm_auto_price']) == 0) 84 { 85 $this->smm_cron['smm_auto_price'] = gmdate( 'Y-m-d H:i:s', time() + $this->minute ); 86 update_option( 'smm_cron', json_encode($this->smm_cron)); 87 } 88 else{ 89 do_action('smm_auto_price'); 90 // Next Scchedule in sting format and update db 91 92 } 93 } 94 } 95 else{ 96 $this->smm_cron['smm_auto_price'] = 0 ; 97 update_option( 'smm_cron', json_encode($this->smm_cron)); 98 update_option( 'active_cron_servers', "N/A" ); 99 } 60 100 61 101 … … 68 108 } 69 109 110 public function set_cron_price_update() { 111 112 $ve = get_option( 'gmt_offset' ) > 0 ? '+' : '-'; 113 $time_start = strtotime( '00:00 ' . $ve . get_option( 'gmt_offset' ) . ' HOURS' ); 114 //do_action('smm_auto_price', $this); 115 if ( ! wp_next_scheduled( 'smm_auto_price' ) ) { 116 wp_schedule_event( time(), 'hourly', 'smm_auto_price' ); 117 //do_action('smm_auto_price', $this); 118 //smapi_renew_orders calls renew order 119 } 120 } 70 121 71 122 public function set_cron() { … … 221 272 222 273 } 274 275 // Auto price Update for SMM products if cron enabled 276 public function smm_auto_price_cron($price_update){ 277 global $wpdb; 278 $smm_server_post_id = array(); 279 $smm_api_items = array(); 280 $table_api_ser = array(); 281 $smm_api_items_str =''; 282 $smm_api_item_meta_raw = array(); 283 284 $_smm_item = array(); 285 $args = array( 286 'post_type' => 'smapi_server', 287 'post_status' => 'any', 288 'posts_per_page' => -1, 289 ); 290 $posts = get_posts( $args );//get all posts type smapi_server 291 if ( $posts != NULL ){ 292 293 foreach($posts as $post) { 294 // get post ID is server Ids 295 $smm_api_items_str = get_post_meta( $post->ID, '_parameter_handle', true ); 296 $smm_api_items = json_decode($smm_api_items_str,true);// STR TO ARR 297 if($smm_api_items['smm_price_update'] === "1"){ //check price update is enabled 298 // load products that uses api items 299 $update_cycle = $smm_api_items['api_price_update']; 300 switch ($update_cycle) { 301 case "daily": 302 $cron_cycle = 86400; 303 break; 304 case "weekly": 305 $cron_cycle = 604800; 306 break; 307 case "monthly": 308 $cron_cycle = 2628000; 309 break; 310 default: 311 $cron_cycle = 60; 312 } 313 // update cron cyclone based on smm api server parameter handle settings 314 $this->smm_cron['smm_auto_price'] = gmdate( 'Y-m-d H:i:s', time() + $cron_cycle ); 315 update_option( 'smm_cron', json_encode($this->smm_cron)); 316 317 $new_api_item = new SMAPI_Api($post->ID); // get api server data 318 $api_item_object = $new_api_item->services(); 319 if($api_item_object == null) continue; //if no object then goto next iteration 320 321 $table_api_service = (array)$api_item_object ?? null; //null use prevent php warning 322 323 324 foreach($table_api_service as $key=>$table_rows){ // getting only price from api server 325 $table_api_serv[$table_api_service[$key]->service] = $table_api_service[$key]->rate; 326 } 327 //file_put_contents(plugin_dir_path( __FILE__ )."check.txt",json_encode($table_api_serv)); 328 329 //$table_api_ser = json_decode(file_get_contents(plugin_dir_path( __FILE__ )."check.txt"),true); 330 $this->smm_api_ids = $table_api_ser; 331 332 $smm_api_item_meta_raw = get_post_meta( $post->ID); 333 $_product_use_api = array(); 334 foreach ( $smm_api_item_meta_raw as $key => $value ) { 335 336 337 if(substr($key, 0, 6) == '_item_'){ 338 339 $find_service = substr($key, 6); //get value after_item_ 340 341 $_smm_item = json_decode(reset($value),true);//reset to get first element 342 343 // check local site price and server price from api query 344 $_smm_item_price = $table_api_ser[$find_service] ?? $_smm_item["f_item_price"]; 345 if($_smm_item["f_item_price"] != $_smm_item_price ) 346 { //changed price goto DB for smm api items 347 $_smm_item["f_item_price"] = $_smm_item_price ; 348 update_post_meta( $post->ID,$key,wp_json_encode($_smm_item,JSON_FORCE_OBJECT | JSON_NUMERIC_CHECK)); 349 $this->smm_api_pro = $this->smm_api_products($post->ID, $key); 350 } 351 352 353 } 354 } 355 $_item_price_updated = array();//stops undefined warning in foreach loop 356 foreach($this->smm_api_pro as $smm_api_prod){ 357 358 //updates the price of products 359 $_updated_product = $this->smm_set_product_price($smm_api_prod) ?? null; 360 if(!empty($_updated_product)) 361 array_push($_item_price_updated, $_updated_product); 362 363 } 364 $_server_ids = array(); 365 if (!array_key_exists($post->ID, $smm_server_post_id))// ✅ Prevents "Undefined array key" error 366 array_push($smm_server_post_id,[$smm_server_post_id[$post->ID] => $smm_api_items['smm_price_update']]) ?? null; 367 array_push($_server_ids, $post->ID); 368 } 369 } 370 } 371 $_pro_updated = empty($_item_price_updated) ? "No price change" : implode(",",$_item_price_updated); 372 $result = implode(",",$_server_ids)." scheduled ".$update_cycle." and Last Executed: ".'-'.$_pro_updated; 373 374 update_option( 'active_cron_servers', $result ); 375 }// END FUNC 376 /** 377 * Sets product ids of api item . 378 * @param N/A 379 * @return array of product Ids 380 */ 381 // Get all products that use the api items 382 public function smm_api_products($_server_id = '',$_item_val =''){ 383 384 //===========================product ids that has smm_api=========== 385 386 $args = array( 387 'post_type' => 'product', 388 'posts_per_page' => -1, // Get all matching products 16978 389 'meta_key' => '_smapi_api', 390 'meta_value' => 'yes', 391 'fields' => 'ids', // Only retrieve product IDs 392 'meta_query' => array( 393 //'key' => '_smapi_service_id_option', 394 //'value' => '_item_', 395 //'compare' => 'LIKE' 396 'key' => '_smapi_server_name_option',//one server 397 'value' => $_server_id, 398 'compare' => '=' 399 400 ) 401 ); 402 $argv = array( 403 'post_type' => 'product_variation', 404 'posts_per_page' => -1, // Get all matching products 405 'meta_key' => 'variable_smm_api', 406 'meta_value' => 'on', 407 'fields' => 'ids', // Only retrieve product IDs var_smapi_service_id_option 408 'meta_query' => array( 409 'key' => 'var_smapi_server_name_option',//one server 410 'value' => $_server_id, 411 'compare' => '=' 412 413 ) 414 ); 415 416 $product_api = array();//avoids undefined warning in foreach 417 $simple_products_ids = get_posts( $args );//get all simple prod 418 foreach($simple_products_ids as $simple_products_id){ 419 if($_item_val == get_post_meta( $simple_products_id, '_smapi_service_id_option', true )) 420 array_push($product_api, "S".$simple_products_id); 421 } 422 $variable_products_ids = get_posts( $argv );//get all var prod 423 foreach($variable_products_ids as $variable_products_id){ 424 if($_item_val == strtok( get_post_meta( $variable_products_id, 'var_smapi_service_id_option', true ), " ")) 425 { 426 $parent_id = wp_get_post_parent_id($variable_products_id); 427 array_push($product_api, "V".$parent_id); 428 } 429 } 430 431 // Output product IDs 432 return array_unique($product_api);//unique ids 433 //=====================get id ends============= 434 435 436 437 } 438 439 /** 440 * Sets product price based on api item price. 441 * @param int|WC_Product $product Product ID or WC_Product object. 442 * @param string $price Price. 443 * @param string $regular_or_sale Price type. Possible values: regular, sale. Default: regular. 444 * @param bool $apply_to_all_variations Whether to set the price for all product variations as well. 445 Default: false. 446 * 447 * @return bool 448 */ 449 function smm_set_product_price($products_id ='') { 450 451 $_regular_price_percentage = (get_option('smmreg_price') != '')?get_option('smmreg_price')/100:0.3; 452 $_sale_price_percentage = (get_option('smmsale_price') != '')?get_option('smmsale_price')/100:NULL; 453 $product_id = filter_var($products_id, FILTER_SANITIZE_NUMBER_INT); 454 // Get an instance of the product object 455 456 $_service_id = get_post_meta( $product_id, '_smapi_service_id_option', true ); 457 458 if ( substr($products_id, 0, 1) == 'S' && $_service_id != "") 459 { 460 $_product = new WC_Product($product_id); 461 462 $_service_id_num = substr($_service_id, 6); //get value after _item_ 463 $_service_price = array_key_exists($_service_id_num, $this->smm_api_ids) ? $this->smm_api_ids[$_service_id_num]:''; 464 //updates products that has new price from server 465 if(!empty($_service_price)){ 466 $_regular_price = $_service_price/1000 * $_regular_price_percentage; 467 $_sale_price = $_service_price/1000 * $_sale_price_percentage; 468 469 470 if ( $_product->is_on_sale() ) { 471 $_product->set_sale_price( $_sale_price ); 472 $_product->set_regular_price( $_regular_price ); 473 } else { 474 $_product->set_regular_price( $_regular_price ); 475 } 476 477 $_product->save(); 478 return "s#".$product_id; 479 } 480 481 } 482 elseif ( substr($products_id, 0, 1) == 'V' ) { 483 484 $smm_service_ids = array(); 485 $smm_service_id = ''; 486 $_smapi_api_check = "on"; 487 // Get the parent product object (variable product) 488 $product = new WC_Product_Variable($product_id); 489 foreach ( $product->get_children() as $variation_id ) { 490 //checking smm api checkbox ON 491 if(get_post_meta( $variation_id, 'variable_smm_api', true ) != "on") 492 $_smapi_api_check = "off" ; 493 //Getting last word as service id 494 495 $_item_number = strtok( get_post_meta( $variation_id, 'var_smapi_service_id_option', true ), " "); 496 497 array_push($smm_service_ids,filter_var($_item_number, FILTER_SANITIZE_NUMBER_INT)); 498 } 499 // check sale product and unsimilar service ids change price only if smm check enabled 500 if( !(count(array_unique($smm_service_ids, SORT_REGULAR)) === 1) && $_smapi_api_check == "on" ) { 501 foreach ( $product->get_children() as $variation_id ) { 502 503 $_item_number = strtok( get_post_meta( $variation_id, 'var_smapi_service_id_option', true ), " "); 504 $_service_id_num = filter_var($_item_number, FILTER_SANITIZE_NUMBER_INT); 505 $_service_price = array_key_exists($_service_id_num, $this->smm_api_ids) ? $this->smm_api_ids[$_service_id_num]:''; 506 507 if(!empty($_service_price)){ 508 $_regular_price_var = $_service_price / 1000 * $_regular_price_percentage; 509 $_sale_price_var = $_service_price / 1000 * $_sale_price_percentage; 510 511 $variation = wc_get_product_object( 'variation', $variation_id ); 512 if($variation->is_on_sale() && $_sale_price_percentage != NULL){ 513 $variation->set_props( 514 array( 515 'regular_price' => $_regular_price_var, 516 'sale_price' => $_sale_price_var, 517 ) 518 ); 519 $variation->save(); 520 } 521 if(!$variation->is_on_sale()){ 522 $variation->set_props( 523 array( 524 'regular_price' => $_regular_price_var, 525 526 ) 527 ); 528 $variation->save(); 529 } 530 } 531 } 532 } return "v#".$product_id.PHP_EOL; 533 }//end elseif 534 } 223 535 } 224 536 } … … 232 544 return SMAPI_Subscription_Cron::get_instance(); 233 545 } 234 -
smm-api/trunk/init.php
r3200206 r3266493 4 4 Plugin URI: https://softnwords.com/themes/plugins/smm-api/ 5 5 Description: SMM API Plugin helps online order processing at remote SMM servers.Best for SMM Panel websites and triggers orders at backend.It shows reports in Admin page. 6 Version: 6.0.2 76 Version: 6.0.28 7 7 Author: Softnwords 8 8 Author URI: https://softnwords.com … … 76 76 $timestamp = wp_next_scheduled( 'smapi_trash_cancelled_subscriptions' ); 77 77 wp_unschedule_event( $timestamp, 'smapi_trash_cancelled_subscriptions' ); 78 $timestamp = wp_next_scheduled( 'smm_auto_price' ); 79 wp_unschedule_event( $timestamp, 'smm_auto_price' ); 78 80 } 79 81 if ( !function_exists( 'smms_smapi_install_woocommerce_admin_notice' ) ) { … … 121 123 } 122 124 123 add_action( ' plugins_loaded', 'smms_smapi_install', 11 );125 add_action( 'woocommerce_loaded', 'smms_smapi_install', 11 ); 124 126 } 125 127 … … 142 144 } 143 145 144 // Load SMAPI text domain ___________________________________ 145 load_plugin_textdomain( 'smm-api', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 146 146 147 147 if( ! class_exists( 'WP_List_Table' ) ) { 148 148 require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); … … 189 189 } 190 190 add_action( 'smms_smapi_init', 'smms_smapi_constructor' ); 191 add_action('init', function() 192 { 193 // Load SMAPI text domain ___________________________________ 194 load_plugin_textdomain( 'smm-api', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 195 }); -
smm-api/trunk/plugin-fw/assets/css/smms-fields.css
r3166708 r3266493 2131 2131 border: 5px solid #C5D7E2; 2132 2132 box-shadow: 3px 3px 5px #888; 2133 position: absolute;2133 position: relative; 2134 2134 top: 15%; 2135 2135 left: 35%; -
smm-api/trunk/plugin-fw/smm-plugin.php
r3174476 r3266493 49 49 50 50 // load from theme folder... 51 load_textdomain( 'smm-api', get_template_directory() . '/core/plugin-fw/smm-api-' . apply_filters( 'plugin_locale', get_locale(), 'smm-api' ) . '.mo' )51 //load_textdomain( 'smm-api', get_template_directory() . '/core/plugin-fw/smm-api-' . apply_filters( 'plugin_locale', get_locale(), 'smm-api' ) . '.mo' ) 52 52 53 53 // ...or from plugin folder 54 ||load_textdomain( 'smm-api', dirname(__FILE__) . '/languages/smm-api-' . apply_filters( 'plugin_locale', get_locale(), 'smm-api' ) . '.mo' );54 load_textdomain( 'smm-api', dirname(__FILE__) . '/languages/smm-api-' . apply_filters( 'plugin_locale', get_locale(), 'smm-api' ) . '.mo' ); 55 55 56 56 add_filter( 'plugin_row_meta', 'smm_plugin_fw_row_meta', 20, 4 ); -
smm-api/trunk/plugin-options/privacy-options.php
r3171967 r3266493 49 49 'default' => 'no' 50 50 ), 51 'cron_price-update' => array( 52 'name' => __('Auto Price Update','smm-api'), 53 'desc-inline' => sprintf('Server# %1s', esc_html(get_option( 'active_cron_servers' ) )), 54 'desc' => sprintf('Scheduled at %1s and Status : %2s', 55 esc_html( SMAPI_Subscription_Cron()->smm_cron['smm_auto_price']) 56 , 57 esc_html(get_option( 'smapi_price_update' )) ), 58 'id' => 'smapi_price_update', 59 'type' => 'smms-field', 60 'smms-type' => 'onoff', 61 'default' => 'no', 62 ), 51 63 52 64 'section_end_privacy_settings'=> array( -
smm-api/trunk/readme.txt
r3200209 r3266493 5 5 Requires at least: 4.9.9 6 6 Tested up to: 6.6 7 Stable tag: 6.0.2 77 Stable tag: 6.0.28 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 103 103 == Changelog == 104 104 105 = 6.0.2 7=106 107 * HPOS bug fixed and new release105 = 6.0.28= 106 107 * HPOS bug fixed /Auto price update feature added 108 108 109 109 = 6.0.9= … … 174 174 == Upgrade Notice == 175 175 176 = 6.0.2 7=177 178 * Fixed per guidelines and release.176 = 6.0.28 = 177 178 * Auto price update feature added. 179 179 180 180 = 6.0.9=
Note: See TracChangeset
for help on using the changeset viewer.