PHP - Wordpress Plugin Help
Hi
I need to add one more function in my wordpress plugin. below is the sample code working for 2nd tier. Now i need a same function for 3rd and 4th tire.
Function explanation
I am A and i refer B and if B made any sale means I (A) will get direct commission for that sale.
If B refer C and if C made any sale means (B) will get direct commission for that sale. And in this sample code me(A) also get commission for that sale as a 2nd tier.
Now C refer D and if D made any sale means © will get direct commission for that sale and (B) will get 2nd tier commission. So here (A) me too should get 3rd tire commission and i need that function.
Please help me.
function wp_aff_award_second_tier_commission($wp_aff_affiliates_db,$sale_amount,$txn_id,$item_id,$buyer_email,$buyer_name='') { global $aff_tx_msg; $clientdate = (date ("Y-m-d")); $clienttime = (date ("H:i:s")); if (get_option('wp_aff_use_2tier') && !empty($wp_aff_affiliates_db->referrer)) { $aff_tx_msg .= '<br />Using tier model'; wp_affiliate_log_debug("Using tier model",true); $award_tier_commission = true; $duration = get_option('wp_aff_2nd_tier_duration'); if(!empty($duration)) { $join_date = $wp_aff_affiliates_db->date; $days_since_joined = round((strtotime(date("Y-m-d")) - strtotime($join_date) ) / (60 * 60 * 24)); if ($days_since_joined > $duration) { $aff_tx_msg .= '<br />Tier commission award duration expried'; wp_affiliate_log_debug("Tier commission award duration expried! No tier commission will be awarded for this sale.",true); $award_tier_commission = false; } } if ($award_tier_commission) { if(!empty($wp_aff_affiliates_db->sec_tier_commissionlevel)){ $second_tier_commission_level = $wp_aff_affiliates_db->sec_tier_commissionlevel; wp_affiliate_log_debug("Using the affiliate specific 2nd tier commission for this referral. 2nd tier commission level: ".$second_tier_commission_level,true); } else{ $second_tier_commission_level = get_option('wp_aff_2nd_tier_commission_level'); wp_affiliate_log_debug("Using global 2nd tier commission for this referral. 2nd tier commission level: ".$second_tier_commission_level,true); } if (get_option('wp_aff_use_fixed_commission')) { $commission_amount = $second_tier_commission_level; } else { $commission_amount = round(($second_tier_commission_level * $sale_amount)/100,2); } $campaign_id = ""; $is_tier_comm = "yes"; global $wpdb; $aff_sales_table = WP_AFF_SALES_TBL_NAME; $updatedb = "INSERT INTO $aff_sales_table (refid,date,time,browser,ipaddress,payment,sale_amount,txn_id,item_id,buyer_email,campaign_id,buyer_name,is_tier_comm) VALUES ('$wp_aff_affiliates_db->referrer','$clientdate','$clienttime','','','$commission_amount','$sale_amount','$txn_id','$item_id','$buyer_email','$campaign_id','$buyer_name','$is_tier_comm')"; $results = $wpdb->query($updatedb); $aff_tx_msg .= '<br />Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount; wp_affiliate_log_debug('Tier commission awarded to: '.$wp_aff_affiliates_db->referrer.'. Commission amount: '.$commission_amount,true); } } return $aff_tx_msg; } Similar TutorialsThis topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=334215.0 <?php /** * Plugin Name: Esewa * Plugin URI: https://kamalparajuli.com.np * Author Name: Kamal Parajuli * Author URI: https://kamalparajuli.com.np * Description: This plugin allows for local content payment systems. * Version: 0.1.0 * License: 0.1.0 * License URL: http://www.gnu.org/licenses/gpl-2.0.txt * text-domain: pay-esewa */ if ( ! in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) return; add_action( 'plugins_loaded', 'noob_payment_init', 11 ); function noob_payment_init() { if( class_exists( 'WC_Payment_Gateway' ) ) { class WC_Noob_pay_Gateway extends WC_Payment_Gateway { public function __construct() { $this->id = 'noob_payment'; $this->icon = apply_filters( 'woocommerce_noob_icon', plugins_url('/assets/icon.png', __FILE__ ) ); $this->has_fields = true; $this->method_title = __( 'Noob Payment', 'noob-pay-woo'); $this->method_description = __( 'Noob local content payment systems.', 'noob-pay-woo'); $this->title = $this->get_option( 'title' ); $this->description = $this->get_option( 'description' ); $this->instructions = $this->get_option( 'instructions', $this->description ); $this->init_form_fields(); $this->init_settings(); add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) ); // add_action( 'woocommerce_thank_you_' . $this->id, array( $this, 'thank_you_page' ) ); } public function init_form_fields() { $this->form_fields = apply_filters( 'woo_noob_pay_fields', array( 'enabled' => array( 'title' => __( 'Enable payment', 'noob-pay-woo'), 'type' => 'checkbox', 'label' => __( 'Tick mark means its enabled.', 'noob-pay-woo'), 'default' => 'no' ), 'title' => array( 'title' => __( 'Esewa Payment', 'noob-pay-woo'), 'type' => 'text', 'default' => __( 'Esewa Payment', 'noob-pay-woo'), 'desc_tip' => true, 'description' => __( 'Add a new title for the Esewa Payment that customers will see when they are in the checkout page.', 'noob-pay-woo') ), 'description' => array( 'title' => __( 'Esewa Payment Description', 'noob-pay-woo'), 'type' => 'textarea', 'default' => __( 'Please remit your payment to the shop to allow for the delivery to be made', 'noob-pay-woo'), 'desc_tip' => true, 'description' => __( 'Add a new title for the Esewa Payment that customers will see when they are in the checkout page.', 'noob-pay-woo') ), 'instructions' => array( 'title' => __( 'Instructions', 'noob-pay-woo'), 'type' => 'textarea', 'default' => __( 'Default instructions', 'noob-pay-woo'), 'desc_tip' => true, 'description' => __( 'Instructions that will be added to the thank you page and order email', 'noob-pay-woo') ), // 'enable_for_virtual' => array( // 'title' => __( 'Accept for virtual orders', 'woocommerce' ), // 'label' => __( 'Accept COD if the order is virtual', 'woocommerce' ), // 'type' => 'checkbox', // 'default' => 'yes', // ), )); } public function process_payments( $order_id ) { $order = wc_get_order( $order_id ); $order->update_status( 'on-hold', __( 'Awaiting Noob Payment', 'noob-pay-woo') ); // if ( $order->get_total() > 0 ) { // Mark as on-hold (we're awaiting the cheque). // } else { // $order->payment_complete(); // } // $this->clear_payment_with_api(); $order->reduce_order_stock(); WC()->cart->empty_cart(); return array( 'result' => 'success', 'redirect' => $this->get_return_url( $order ), ); } // public function clear_payment_with_api() { // } public function thank_you_page(){ if( $this->instructions ){ echo wpautop( $this->instructions ); } } } } } add_filter( 'woocommerce_payment_gateways', 'add_to_woo_noob_payment_gateway'); function add_to_woo_noob_payment_gateway( $gateways ) { $gateways[] = 'WC_Noob_pay_Gateway'; return $gateways; }
this is my plugin code. I want to display a QR code below the description so people can scan that qr code and pay. However I cannot understand how to let admin upload his/her Qr code and how to display it on checkout page just like description. Edited July 13 by Barandcode tags added This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=314030.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=322006.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=348006.0 I'm working with a Wordpress plugin that uses that google maps api to map multiple markers depending on search terms and proximity. You can set an option so that, regardless of the default proximity when the page loads, ALL markers will first appear. In order to help with performance, the authors decided to limit that option to 250 markers. I need to lift that limit to 5,000 (though I currently only have about 500, I don't want to deal with limits as my markers grow).
Based on a comment made in one of the php files it appears the authors enforce the limit in the query itself so I'm pasting the code for the php file that performs the query. Please let me know if there is something else I should do, if this forum is the wrong place or if I should be posting on pastebin and linking rather than dumping the entire file between code tags. Thanks in advance!
<?php if ( !class_exists( 'SM_XML_Search' ) ){ class SM_XML_Search{ // Register hook to perform the search function sm_xml_search() { add_action( 'template_redirect', array( &$this, 'init_search' ) ); } // Inits the search process. Collects default options, search options, and queries DB function init_search() { if ( isset( $_GET['sm-xml-search'] ) ) { global $wpdb, $simple_map; remove_filter( 'the_title', 'at_title_check' ); $defaults = array( 'lat' => false, 'lng' => false, 'radius' => false, 'namequery' => false, 'query_type' => 'distance', 'address' => false, 'city' => false, 'state' => false, 'zip' => false, 'onlyzip' => false, 'country' => false, 'limit' => false, 'pid' => 0, ); $input = array_filter( array_intersect_key( $_GET, $defaults ) ) + $defaults; $smtaxes = array(); if ( $taxonomies = get_object_taxonomies( 'sm-location' ) ) { foreach ( $taxonomies as $key => $tax ) { $phpsafe = str_replace( '-', '_', $tax ); $_GET += array( $phpsafe => '' ); $smtaxes[$tax] = $_GET[$phpsafe]; } } // Define my empty strings $distance_select = $distance_having = $distance_order = ''; // We're going to do a hard limit to 500 for now. if ( !$input['limit'] || $input['limit'] > 500 ) $limit = "LIMIT 500"; else $limit = 'LIMIT ' . absint( $input['limit'] ); $limit = apply_filters( 'sm-xml-search-limit', $limit ); // Locations within specific distance or just get them all? $distance_select = $wpdb->prepare( "( 3959 * ACOS( COS( RADIANS(%s) ) * COS( RADIANS( lat_tbl.meta_value ) ) * COS( RADIANS( lng_tbl.meta_value ) - RADIANS(%s) ) + SIN( RADIANS(%s) ) * SIN( RADIANS( lat_tbl.meta_value ) ) ) ) AS distance", $input['lat'], $input['lng'], $input['lat'] ) . ', '; $distance_order = 'distance, '; if ( $input['radius'] ) { $input['radius'] = ( $input['radius'] < 1 ) ? 1 : $input['radius']; $distance_having = $wpdb->prepare( "HAVING distance < %d", $input['radius'] ); } $i = 1; $taxonomy_join = ''; foreach ( array_filter( $smtaxes ) as $taxonomy => $tax_value ) { $term_ids = explode( ',', $tax_value ); if ( $term_ids[0] == 'OR' ) { unset( $term_ids[0] ); if ( empty( $term_ids ) ) { continue; } $search_values = array( "IN (" . vsprintf( '%d' . str_repeat( ',%d', count( $term_ids ) - 1 ), $term_ids ) . ")" ); } else { $search_values = array(); foreach ( $term_ids as $term_id ) { $search_values[] = sprintf( '= %d', $term_id ); } } foreach ( $search_values as $search_value ) { $taxonomy_join .= " INNER JOIN $wpdb->term_relationships AS term_rel_$i ON posts.ID = term_rel_$i.object_id INNER JOIN $wpdb->term_taxonomy AS tax_$i ON term_rel_$i.term_taxonomy_id = tax_$i.term_taxonomy_id AND tax_$i.taxonomy = '$taxonomy' AND tax_$i.term_id $search_value "; $i++; } } $sql = "SELECT lat_tbl.meta_value AS lat, lng_tbl.meta_value AS lng, $distance_select posts.ID, posts.post_content, posts.post_title FROM $wpdb->posts AS posts INNER JOIN $wpdb->postmeta lat_tbl ON lat_tbl.post_id = posts.ID AND lat_tbl.meta_key = 'location_lat' INNER JOIN $wpdb->postmeta lng_tbl ON lng_tbl.post_id = posts.ID AND lng_tbl.meta_key = 'location_lng' $taxonomy_join WHERE posts.post_type = 'sm-location' AND posts.post_status = 'publish' GROUP BY posts.ID $distance_having ORDER BY " . apply_filters( 'sm-location-sort-order', $distance_order . ' posts.post_name ASC', $input ) . " " . $limit; $sql = apply_filters( 'sm-xml-search-locations-sql', $sql ); // TODO: Consider using this to generate the marker node attributes in print_xml(). $location_field_map = array( 'location_address' => 'address', 'location_address2' => 'address2', 'location_city' => 'city', 'location_state' => 'state', 'location_zip' => 'zip', 'location_country' => 'country', 'location_phone' => 'phone', 'location_fax' => 'fax', 'location_email' => 'email', 'location_url' => 'url', 'location_special' => 'special', ); $options = $simple_map->get_options(); $show_permalink = !empty( $options['enable_permalinks'] ); if ( $locations = $wpdb->get_results( $sql ) ) { // Start looping through all locations i found in the radius foreach ( $locations as $key => $value ) { // Add postmeta data to location $custom_fields = get_post_custom( $value->ID ); foreach ( $location_field_map as $key => $field ) { if ( isset( $custom_fields[$key][0] ) ) { $value->$field = $custom_fields[$key][0]; } else { $value->$field = ''; } } $value->postid = $value->ID; $value->name = apply_filters( 'the_title', $value->post_title ); $the_content = trim( $value->post_content ); if ( !empty( $the_content ) ) { $the_content = apply_filters( 'the_content', $the_content ); } $value->description = $the_content; $value->permalink = ''; if ( $show_permalink ) { $value->permalink = get_permalink( $value->ID ); $value->permalink = apply_filters( 'the_permalink', $value->permalink ); } // List all terms for all taxonomies for this post $value->taxes = array(); foreach ( $smtaxes as $taxonomy => $tax_value ) { $phpsafe_tax = str_replace( '-', '_', $taxonomy ); $local_tax_names = ''; // Get all taxes for this post if ( $local_taxes = wp_get_object_terms( $value->ID, $taxonomy, array( 'fields' => 'names' ) ) ) { $local_tax_names = implode( ', ', $local_taxes ); } $value->taxes[$phpsafe_tax] = $local_tax_names; } } } else { // Print empty XML $locations = array(); } $locations = apply_filters( 'sm-xml-search-locations', $locations ); $this->print_json( $locations, $smtaxes ); } } // Prints the JSON output function print_json( $dataset, $smtaxes ) { header( 'Status: 200 OK', false, 200 ); header( 'Content-type: application/json' ); do_action( 'sm-xml-search-headers' ); do_action( 'sm-print-json', $dataset, $smtaxes ); echo json_encode( $dataset ); die(); } } } This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=306092.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=349156.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=323633.0 I wanted to develop a Wordpress plugin. There's a few existing plugins for the subject I wanted to code. I thought I would get some inspiration by looking at the code. It's a gigantic mess of spaghetti! The code I looked at, looks like it's been made using an IDE. There seems to be so many folders and files - it's crazy. Others I looked at seem to be similar. It seems like an enterprise application. I'm more than capable of writing a spec and coding myself. The only thing I'm missing would be Wordpress practices - setting up tables and using hooks and other things. Any advice? Or do I just get dirty and sink my head into the code and untangle? QUESTIONS: - Do you use an IDE to code PHP? - What are the most popular IDE's? Thanks. This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=318539.0 dear folks
this question is regarding the plugin update, file uploader and SFTP - on a wordpress that runs on secured- server
I think I know the answer to the following question as "not possible" but I figured I would check. my sites are on servers where we disable FTP access and only use SFTP access, and also on a different port (not port 22). what if i want to use a automated maintaining service like the following https://mainwp.com http://wwww.infinitewp.com automated Installing and updating plugins to the sites does not seem to work and I assume this is the reason why. I'm also assuming the File uploader extension will not work either. Can anyone confirm this for sure though? Any ideas as far as workaround? one might think of the following way: Can you try adding your SFTP settings into the wp-config of one of my sites to see if that allows the functions to work? we can see an example in http://codex.wordpre...g_wp-config.php under WordPress Upgrade Constants or possibly try this plugin SSH SFTP Updater Support do you have any idear!? cf: https://mainwp.com/f...&highlight=sftp I have a php tutorial that I followed for creating, inserting, selecting and updating a MySQL database with php. Everything works fine so I wanted to put it into Wordpress. I took the code and placed it into the wordpress page and everything worked just fine except the update function. Here is the tutorial I used. http://www.phpsimple.net/mysql_insert_record.html It is also the part I am having trouble with. I am able to create a record and I am also able to select a record but when I choose "update" the form doesn't load the data. It will outside the website but not inside wordpress. I am hoping this is not vague but because of my inexperience I am not sure what else to say. I will be more than happy to provide any other information you need. Greetings! I'm a newbie in php programming started with learning wordpress. I'm working on a local machine and trying to modifying a woocommerce order report plugin. The issue i'm facing is this order report plugin shows only 1 product name even though customer ordered multiple products. I want to show all product names. Your help will be much appreciated
<?php // Add the Product Sales Report to the WordPress admin add_action('admin_menu', 'hm_psrf_admin_menu'); function hm_psrf_admin_menu() { add_submenu_page('woocommerce', 'Custom Order Report', 'Custom Order Report', 'view_woocommerce_reports', 'hm_sbpf', 'hm_sbpf_page'); } function hm_psrf_default_report_settings() { return array( 'report_time' => '30d', 'report_start' => date('Y-m-d', current_time('timestamp') - (86400 * 31)), 'report_end' => date('Y-m-d', current_time('timestamp') - 86400), 'order_statuses' => array('wc-processing', 'wc-on-hold', 'wc-completed'), 'products' => 'all', 'product_cats' => array(), 'product_ids' => '', 'variations' => 0, 'orderby' => 'quantity', 'orderdir' => 'desc', 'fields' => array('product_id', 'product_sku', 'product_name', 'quantity_sold', 'gross_sales'), 'limit_on' => 0, 'limit' => 10, 'include_header' => 1, 'exclude_free' => 0 ); } // This function generates the Product Sales Report page HTML function hm_sbpf_page() { $savedReportSettings = get_option('hm_psr_report_settings'); if (isset($_POST['op']) && $_POST['op'] == 'preset-del' && !empty($_POST['r']) && isset($savedReportSettings[$_POST['r']])) { unset($savedReportSettings[$_POST['r']]); update_option('hm_psr_report_settings', $savedReportSettings); $_POST['r'] = 0; echo('<script type="text/javascript">location.href = location.href;</script>'); } $reportSettings = (empty($savedReportSettings) ? hm_psrf_default_report_settings() : array_merge(hm_psrf_default_report_settings(), $savedReportSettings[ isset($_POST['r']) && isset($savedReportSettings[$_POST['r']]) ? $_POST['r'] : 0 ] )); // For backwards compatibility with pre-1.4 versions if (!empty($reportSettings['cat'])) { $reportSettings['products'] = 'cats'; $reportSettings['product_cats'] = array($reportSettings['cat']); } $fieldOptions = array( 'order_id' => 'Order ID', /*'product_id' => 'Product ID',*/ 'customer_name' => 'Customer Name', /*'variation_id' => 'Variation ID',*/ 'city' => 'City', 'address' => 'Address', 'product_name' => 'Product Name', 'quantity_sold' => 'Quantity Sold', /*'product_sku' => 'Product SKU',*/ 'gross_sales' => 'Gross Sales', 'product_categories' => 'Schools', /*'variation_attributes' => 'Variation Attributes',*/ /*'gross_after_discount' => 'Gross Sales (After Discounts)'*/ 'ceremony_date' => 'Ceremony Date', 'ceremony_time' => 'Ceremony Time', 'customer_note' => 'Additional Information', ); include(dirname(__FILE__).'/admin.php'); } // Hook into WordPress init; this function performs report generation when // the admin form is submitted add_action('init', 'hm_sbpf_on_init', 9999); function hm_sbpf_on_init() { global $pagenow; // Check if we are in admin and on the report page if (!is_admin()) return; if ($pagenow == 'admin.php' && isset($_GET['page']) && $_GET['page'] == 'hm_sbpf' && !empty($_POST['hm_sbp_do_export'])) { // Verify the nonce check_admin_referer('hm_sbpf_do_export'); $newSettings = array_intersect_key($_POST, hm_psrf_default_report_settings()); foreach ($newSettings as $key => $value) if (!is_array($value)) $newSettings[$key] = htmlspecialchars($value); // Update the saved report settings $savedReportSettings = get_option('hm_psr_report_settings'); $savedReportSettings[0] = array_merge(hm_psrf_default_report_settings(), $newSettings); update_option('hm_psr_report_settings', $savedReportSettings); // Check if no fields are selected or if not downloading if (empty($_POST['fields']) || empty($_POST['hm_sbp_download'])) return; // Assemble the filename for the report download $filename = 'Product Sales - '; if (!empty($_POST['cat']) && is_numeric($_POST['cat'])) { $cat = get_term($_POST['cat'], 'product_cat'); if (!empty($cat->name)) $filename .= addslashes(html_entity_decode($cat->name)).' - '; } $filename .= date('Y-m-d', current_time('timestamp')).'.csv'; // Send headers header('Content-Type: text/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"'); // Output the report header row (if applicable) and body $stdout = fopen('php://output', 'w'); if (!empty($_POST['include_header'])) hm_sbpf_export_header($stdout); hm_sbpf_export_body($stdout); exit; } } // This function outputs the report header row function hm_sbpf_export_header($dest, $return=false) { $header = array(); foreach ($_POST['fields'] as $field) { switch ($field) { case 'order_id': $header[] = 'Order ID'; break; case 'product_name': $header[] = 'Product Name'; break; case 'quantity_sold': $header[] = 'Quantity Sold'; break; case 'gross_sales': $header[] = 'Gross Sales'; break; case 'product_categories': $header[] = 'Schools'; break; case 'customer_name': $header[] = 'Customer Name'; break; case 'city': $header[] = 'City'; break; case 'address': $header[] = 'Address'; break; case 'ceremony_date': $header[] = 'Ceremony Date'; break; case 'ceremony_time': $header[] = 'Ceremony Time'; break; case 'customer_note': $header[] = 'Additional Information'; break; } } if ($return) return $header; fputcsv($dest, $header); } // This function generates and outputs the report body rows function hm_sbpf_export_body($dest, $return=false) { global $woocommerce, $wpdb; $product_ids = array(); if ($_POST['products'] == 'cats') { $cats = array(); foreach ($_POST['product_cats'] as $cat) if (is_numeric($cat)) $cats[] = $cat; $product_ids = get_objects_in_term($cats, 'product_cat'); } else if ($_POST['products'] == 'ids') { foreach (explode(',', $_POST['product_ids']) as $productId) { $productId = trim($productId); if (is_numeric($productId)) $product_ids[] = $productId; } } // Calculate report start and end dates (timestamps) switch ($_POST['report_time']) { case '0d': $end_date = strtotime('midnight', current_time('timestamp')); $start_date = $end_date; break; case '1d': $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date; break; case '7d': $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date - (86400 * 6); break; case '1cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight -1month'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '0cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '+1cm': $start_date = strtotime(date('Y-m', current_time('timestamp')).'-01 midnight +1month'); $end_date = strtotime('+1month', $start_date) - 86400; break; case '+7d': $start_date = strtotime('midnight', current_time('timestamp')) + 86400; $end_date = $start_date + (86400 * 6); break; case '+30d': $start_date = strtotime('midnight', current_time('timestamp')) + 86400; $end_date = $start_date + (86400 * 29); break; case 'custom': $end_date = strtotime('midnight', strtotime($_POST['report_end'])); $start_date = strtotime('midnight', strtotime($_POST['report_start'])); break; default: // 30 days is the default $end_date = strtotime('midnight', current_time('timestamp')) - 86400; $start_date = $end_date - (86400 * 29); } // Assemble order by string $orderby = (in_array($_POST['orderby'], array('product_id', 'gross', 'gross_after_discount')) ? $_POST['orderby'] : 'quantity'); $orderby .= ' '.($_POST['orderdir'] == 'asc' ? 'ASC' : 'DESC'); // Create a new WC_Admin_Report object include_once($woocommerce->plugin_path().'/includes/admin/reports/class-wc-admin-report.php'); $wc_report = new WC_Admin_Report(); $wc_report->start_date = $start_date; $wc_report->end_date = $end_date; //echo(date('Y-m-d', $end_date)); $where_meta = array(); if ($_POST['products'] != 'all') { $where_meta[] = array( 'type' => 'order_item_meta', 'meta_key' => '_product_id', 'operator' => 'in', 'meta_value' => $product_ids ); } if (!empty($_POST['exclude_free'])) { $where_meta[] = array( 'meta_key' => '_line_total', 'meta_value' => 0, 'operator' => '!=', 'type' => 'order_item_meta' ); } // Get report data // Avoid max join size error $wpdb->query('SET SQL_BIG_SELECTS=1'); // Prevent plugins from overriding the order status filter add_filter('woocommerce_reports_order_statuses', 'hm_psrf_report_order_statuses', 9999); // Based on woocoommerce/includes/admin/reports/class-wc-report-sales-by-product.php $sold_products = $wc_report->get_order_report_data(array( 'data' => array( '_product_id' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => '', 'name' => 'product_id' ), '_qty' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'quantity' ), '_line_subtotal' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'gross' ), '_line_total' => array( 'type' => 'order_item_meta', 'order_item_type' => 'line_item', 'function' => 'SUM', 'name' => 'gross_after_discount' ), /*usama*/ 'order_id' => array( 'type' => 'order_item', 'order_item_type' => 'line_item', 'function' => '', 'name' => 'order_id' ) /*usama*/ ), 'query_type' => 'get_results', 'group_by' => 'order_id', 'where_meta' => $where_meta, 'order_by' => $orderby, 'limit' => (!empty($_POST['limit_on']) && is_numeric($_POST['limit']) ? $_POST['limit'] : ''), 'filter_range' => ($_POST['report_time'] != 'all'), 'order_types' => wc_get_order_types('order_count'), 'order_status' => hm_psrf_report_order_statuses() )); // Remove report order statuses filter remove_filter('woocommerce_reports_order_statuses', 'hm_psrf_report_order_statuses', 9999); if ($return) $rows = array(); // Output report rows foreach ($sold_products as $product) { $row = array(); /*usama*/ $order = wc_get_order($product->order_id); $customerName = $order->get_billing_first_name().' '.$order->get_billing_last_name(); $billingCity = $order->get_billing_city(); $billingAddress1 = $order->get_billing_address_1(); $note = $order->get_customer_note(); //echo $product->order_id; //echo $customerName.$city.$billingAddress1; //echo '<pre>';print_r($order);exit; /*usama*/ foreach ($_POST['fields'] as $field) { switch ($field) { case 'order_id': $row[] = $product->order_id; break; case 'product_name': $row[] = html_entity_decode(get_the_title($product->product_id)); break; case 'quantity_sold': $row[] = $product->quantity; break; case 'gross_sales': $row[] = $product->gross; break; /*case 'variation_id': $row[] = (empty($product->variation_id) ? '' : $product->variation_id); break; case 'product_sku': $row[] = get_post_meta($product->product_id, '_sku', true); break;*/ case 'product_categories': $terms = get_the_terms($product->product_id, 'product_cat'); if (empty($terms)) { $row[] = ''; } else { $categories = array(); foreach ($terms as $term) $categories[] = $term->name; $row[] = implode(', ', $categories); } break; case 'customer_name': $row[] = $customerName; break; case 'city': $row[] = $billingCity; break; case 'address': $row[] = $billingAddress1; break; case 'customer_note': $row[] = $note; break; /*case 'gross_after_discount': $row[] = $product->gross_after_discount; break;*/ /*usama*/ case 'ceremony_date': $row[] = $order->get_meta( '_billing_myfield12', true ); break; case 'ceremony_time': $row[] = $order->get_meta( '_billing_myfield13', true ); break; case 'customer_note': $row[] = $order->get_meta( '_billing_myfield14', true ); break; } } if ($return) $rows[] = $row; else fputcsv($dest, $row); } if ($return) return $rows; } add_action('admin_enqueue_scripts', 'hm_psrf_admin_enqueue_scripts'); function hm_psrf_admin_enqueue_scripts() { wp_enqueue_style('hm_psrf_admin_style', plugins_url('css/hm-product-sales-report.css', __FILE__)); wp_enqueue_style('pikaday', plugins_url('css/pikaday.css', __FILE__)); wp_enqueue_script('moment', plugins_url('js/moment.min.js', __FILE__)); wp_enqueue_script('pikaday', plugins_url('js/pikaday.js', __FILE__)); } // Schedulable email report hook add_filter('pp_wc_get_schedulable_email_reports', 'hm_psrf_add_schedulable_email_reports'); function hm_psrf_add_schedulable_email_reports($reports) { $reports['hm_psr'] = array( 'name' => 'Product Sales Report', 'callback' => 'hm_psrf_run_scheduled_report', 'reports' => array( 'last' => 'Last used settings' ) ); return $reports; } function hm_psrf_run_scheduled_report($reportId, $start, $end, $args=array(), $output=false) { $savedReportSettings = get_option('hm_psr_report_settings'); if (!isset($savedReportSettings[0])) return false; $prevPost = $_POST; $_POST = $savedReportSettings[0]; $_POST['report_time'] = 'custom'; $_POST['report_start'] = date('Y-m-d', $start); $_POST['report_end'] = date('Y-m-d', $end); $_POST = array_merge($_POST, array_intersect_key($args, $_POST)); if ($output) { echo('<table><thead><tr>'); foreach (hm_sbpf_export_header(null, true) as $heading) { echo("<th>$heading</th>"); } echo('</tr></thead><tbody>'); foreach (hm_sbpf_export_body(null, true) as $row) { echo('<tr>'); foreach ($row as $cell) echo('<td>'.htmlspecialchars($cell).'</td>'); echo('</tr>'); } echo('</tbody></table>'); $_POST = $prevPost; return; } $filename = get_temp_dir().'/Product Sales Report.csv'; $out = fopen($filename, 'w'); if (!empty($_POST['include_header'])) hm_sbpf_export_header($out); hm_sbpf_export_body($out); fclose($out); $_POST = $prevPost; return $filename; } function hm_psrf_report_order_statuses() { $wcOrderStatuses = wc_get_order_statuses(); $orderStatuses = array(); if (!empty($_POST['order_statuses'])) { foreach ($_POST['order_statuses'] as $orderStatus) { if (isset($wcOrderStatuses[$orderStatus])) $orderStatuses[] = substr($orderStatus, 3); } } return $orderStatuses; } /* Review/donate notice */ register_activation_hook(__FILE__, 'hm_psrf_first_activate'); function hm_psrf_first_activate() { $pre = 'hm_psr'; $firstActivate = get_option($pre.'_first_activate'); if (empty($firstActivate)) { update_option($pre.'_first_activate', time()); } } if (is_admin() && get_option('hm_psr_rd_notice_hidden') != 1 && time() - get_option('hm_psr_first_activate') >= (14*86400)) { add_action('admin_notices', 'hm_psrf_rd_notice'); add_action('wp_ajax_hm_psrf_rd_notice_hide', 'hm_psrf_rd_notice_hide'); } function hm_psrf_rd_notice() { $pre = 'hm_psr'; $slug = 'product-sales-report-for-woocommerce'; echo(' <div id="'.$pre.'_rd_notice" class="updated notice is-dismissible"><p>Do you use the <strong>Product Sales Report</strong> plugin? Please support our free plugin by <a href="" target="_blank">making a donation</a>!product-sales-report-for-woocommerce Thanks!</p></div> <script>jQuery(document).ready(function($){$(\'#'.$pre.'_rd_notice\').on(\'click\', \'.notice-dismiss\', function(){jQuery.post(ajaxurl, {action:\'hm_psrf_rd_notice_hide\'})});});</script> '); } function hm_psrf_rd_notice_hide() { $pre = 'hm_psr'; update_option($pre.'_rd_notice_hidden', 1); } ?>
Helo, I am new here. I have a simple " Like " plugin for Vanilla Forums which does it work nicely. Sadly, it won't sent notifications when someone likes our post. I have another plugin from the same author which gives notifications on Profile-Like aka Kick/Poke. I am trying to use the notification part of the Kick plugin ( which I modified at my best to " Like ") added to the " Like " plugin so that I will able to provide notifications to post-authors on receiving a " Like ". I have created a GitHub repo with my attempt so far. It would be nice if someone can help me find a final solution. Thanks https://github.com/meetdilip/Like Hey guys, I hate being a beggar but I am trying to figure out how to remove links from aawp-box__image and aawp-box__title. That’s a script from a plugin that uses Amazon to get the name, images, and other stuff of products directly on my site. I was wondering if there is a way to delete the links while still have the images downloaded from Amazon (the plugin is AAWP). Maybe someone can help me here?
<?php /* * Box template * ------------ * It's possible to display multiple boxes at once * * @package AAWP */ if ( ! defined( 'ABSPATH' ) ) { die( '-1' ); } ?> <?php foreach ( $this->items as $i => $item ) : ?> <?php $this->setup_item($i, $item); ?> <div class="<?php echo $this->get_classes('box'); ?>" <?php $this->the_product_container(); ?>> <div class="aawp-box__thumb"> <a class="aawp-box__image-link" ?>" title="<?php echo $this->get_product_image_link_title(); ?>" rel="nofollow" target="_blank"> <img class="aawp-box__image" src="<?php echo $this->get_product_image(); ?>" alt="<?php echo $this->get_product_image_alt(); ?>" <?php $this->the_product_image_title(); ?> /> </a> <?php if ( $this->get_product_rating() ) { ?> <div class="aawp-box__rating"> <?php echo $this->get_product_star_rating(); ?> <?php if ( $this->get_product_reviews() ) { ?> <div class="aawp-box__reviews"><?php echo $this->get_product_reviews(); ?></div> <?php } ?> </div> <?php } ?> </div> <div class="aawp-box__content"> <a class="aawp-box__title" ?>" title="<?php echo $this->get_product_link_title(); ?>" rel="nofollow" target="_blank"> <?php echo $this->get_product_title(); ?> </a> <div class="aawp-box__description"> <?php echo $this->get_product_description(); ?> </div> </div> <div class="aawp-box__footer"> <?php if ( $this->get_product_is_sale() ) { ?> <span class="aawp-box__ribbon aawp-box__sale"> <?php if ( $this->show_sale_discount() && $this->is_sale_discount_position('ribbon') ) { ?> <?php echo $this->get_saved_text(); ?> <?php } else { ?> <?php echo $this->get_sale_text(); ?> <?php } ?> </span> <?php } ?> <div class="aawp-box__pricing"> <?php if ( $this->get_product_is_sale() && $this->show_sale_discount() ) { ?> <span class="aawp-box__price aawp-box__price--old"><?php echo $this->get_product_pricing('old'); ?></span> <?php if ( $this->is_sale_discount_position('standard') ) { ?> <span class="aawp-box__price aawp-box__price--saved"><?php echo $this->get_saved_text(); ?></span> <?php } ?> <?php } ?> <?php if ( $this->show_advertised_price() ) { ?> <span class="aawp-box__price aawp-box__price--current"><?php echo $this->get_product_pricing(); ?></span> <?php } ?> <?php $this->the_product_check_prime_logo(); ?> </div> <?php echo $this->get_button('detail'); ?> <?php echo $this->get_button(); ?> <?php if ( $this->get_inline_info() ) { ?> <span class="aawp-box__info"><?php echo $this->get_inline_info_text(); ?></span> <?php } ?> </div> </div> <?php endforeach; ?> I hope that isn’t too much hassle, thank you! Hi all, I am working on php project and willing to use the "everything as a plugin" idea so alot of people can easily contribute. I am wondering how I can make a php page that includes my plugins, without having to hardcode them(as in require_once, ...). And afterwards it should be possible to execute a function on each of the enabled plugins. Especially the "hardcode" part I am not sure on how to fix it. As for executing a function for each plugin (so that will be a Class object), I wonder how I can make an object of each class from an interface and then execute a function without hardcoding the creation of all objects. Any one ideas or experience with something like this? Thanks in advance. This topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=327155.0 Hey, Im really confused about the arcitecture of a plugin system... I want to create one for my CMS project, but have no idea on how they actually work, and what the arcitecture of a plugin system would look like... Could someone help me out? Hello everyone. I'm relatively new to PHP, and I'm loving how CakePHP has made my life easy, and hard at the same time. I'm having trouble updating the deprecated Forum Plugin from milesj. If anyone there could help me, I'd much appreciate it. First off, deprecated views and controllers. They amaze me to no end. No matter how deep I try to trace them, it's impossible for me to find out what is wrong with it. I do have an idea, but I can't trace where I should change the codes. Second; admin roles, ACL, CRUD is not a fairly new concept to me now, but because of the deprecated codes I can't get a deeper understanding about why I can't disable new users from accessing the admin panel. Third; the Admin Plugin is good, but wouldn't detect the Forum Plugin correctly. I can't trace back where this went wrong. Also, adding new users through the admin panel doesn't hash the password. My codes are here for your viewing and mockery: http://www.mediafire...1/AsCIISite.rar |