File manager - Edit - /home/palg2351/public_html/klanaobsesiindonesia.com/wp-includes/Text/Diff/Engine/mu-plugins.tar
Back
woowa-per-product.php 0000644 00000022307 15173067051 0010664 0 ustar 00 <?php /** * Plugin Name: Woowa Filter BY Product Notifier (MU) * Author: AlmujabSidik * Version: 1.0 */ if ( ! defined('ABSPATH') ) exit; /* ===== CONFIG ===== */ if ( ! defined('WOOWA_API_URL') ) define('WOOWA_API_URL', 'https://notifapi.com/send_message'); if ( ! defined('WOOWA_API_KEY') ) define('WOOWA_API_KEY', 'adpe29d6075-f85e-47e7-9bd4-bf35665f56a9'); $GLOBALS['FUN_RUN_IDS'] = array(3955); $GLOBALS['VIRTUAL_RUN_IDS'] = array(3952); $GLOBALS['DISTRICT_META_KEYS'] = array('billing_district','_billing_district','district','kecamatan'); add_action('woocommerce_thankyou', 'woowa_send_per_product_message', 9, 1); add_action('woocommerce_order_status_changed', function($order_id, $old_status, $new_status, $order){ if ( in_array( $new_status, array('on-hold','processing','completed'), true ) ) { woowa_send_per_product_message( $order_id ); } }, 9, 4); function woowa_send_per_product_message( $order_id ) { if ( ! $order_id ) return; $order = wc_get_order($order_id); if ( ! $order ) return; // DEBUG: $order->add_order_note('[WOOWA] hook masuk: status='.$order->get_status().' order_id='.$order_id); $order_url = $order->get_checkout_order_received_url(); $pay_url = woowa_get_pay_url( $order ); $pay_title = $order->get_payment_method_title(); if (empty($pay_title)) { $pay_title = ucfirst( str_replace( array('-', '_'), ' ', (string) $order->get_payment_method() ) ); } if ( $order->needs_payment() || $order->has_status( array('pending','on-hold','failed') ) ) { $cta_line = "*Klik untuk bayar ({$pay_title}):*\n{$pay_url}"; } else { $cta_line = "Cek status & riwayat pesanan: {$order_url}"; } $order->add_order_note('[WOOWA] pay_url=' . $pay_url); $status = $order->get_status(); $flag = '_woowa_v2_sent_' . $status; $global_flag = '_woowa_v2_sent_any'; if ( $order->get_meta($global_flag) || $order->get_meta($flag) ) { $order->add_order_note('[WOOWA] SKIP: sudah pernah kirim (ada flag).'); return; } global $FUN_RUN_IDS, $VIRTUAL_RUN_IDS, $DISTRICT_META_KEYS; $contains_fun = false; $contains_virtual = false; foreach ( $order->get_items() as $item ) { $pid = $item->get_product_id(); if ( in_array( $pid, (array)$FUN_RUN_IDS, true ) ) $contains_fun = true; if ( in_array( $pid, (array)$VIRTUAL_RUN_IDS, true ) ) $contains_virtual = true; } if ( ! $contains_fun && ! $contains_virtual ) { $order->add_order_note('[WOOWA] SKIP: tidak menemukan produk Fun/Virtual. Cek ID produk.'); return; } $nama = trim( $order->get_formatted_billing_full_name() ?: $order->get_billing_first_name() ); $email = $order->get_billing_email(); $wa_raw = $order->get_billing_phone(); if ( ! $wa_raw ) { $order->add_order_note('[WOOWA] SKIP: billing_phone kosong.'); return; } $wa_api = woowa_norm_phone_api($wa_raw); $wa_msg = woowa_norm_phone_display($wa_raw); $amount = wp_strip_all_tags( wc_price( $order->get_total(), array('currency' => $order->get_currency()) ) ); $items = $order->get_items(); $first_item = $items ? reset($items) : null; $product_name= $first_item ? $first_item->get_name() : 'Produk'; $district = ''; if ( $contains_virtual ) { foreach ( (array)$DISTRICT_META_KEYS as $k ) { $v = $order->get_meta($k); if ( ! empty($v) ) { $district = $v; break; } } if ( empty($district) ) { foreach ( $order->get_items() as $item ) { foreach ( $item->get_formatted_meta_data('') as $m ) { $lbl = strtolower( trim($m->display_key) ); if ( in_array($lbl, array('district','kecamatan'), true) ) { $district = wp_strip_all_tags($m->display_value); break 2; } } } } } $details_block = woowa_build_order_details_compact( $order, $wa_msg ); // ==== template pesan ==== if ( $contains_fun && ! $contains_virtual ) { $message = "*Terima kasih!* Pendaftaran *Fun Run* diterima.\n" . "Kategori: {$product_name}\n" . "*Total: {$amount}*\n\n" . "*Rincian:*\n" . "Nama: {$nama}\n" . "No WA: {$wa_msg}\n" . "Email: {$email}\n\n" . $cta_line; $order->add_order_note('[WOOWA] template: FUN RUN'); } else { $message = "*Terima kasih!* Pendaftaran *Virtual Run* diterima.\n" . "Kategori: {$product_name}\n" . "*Total: {$amount}*\n\n" . $details_block . "\n" . ( $district ? "Kecamatan : {$district}\n\n" : "\n" ) . $cta_line; $order->add_order_note('[WOOWA] template: VIRTUAL RUN'); } // Notifikasi Ke Order Notes woocommerce $order->add_order_note('[WOOWA] target='.$wa_api.' | len='.strlen($message)); $sent = woowa_send_via_api( $wa_api, $message, $order ); if ( ! $sent ) { $order->add_order_note('[WOOWA] API gagal → coba fallback action'); $sent = woowa_send_via_action( $wa_api, $message, $order ); } if ( $sent ) { $order->update_meta_data( $flag, 1 ); $order->update_meta_data( $global_flag, 1 ); $order->add_order_note('Woowa per-product message: TERKIRIM'); $order->save(); } else { $order->add_order_note('Woowa per-product message: GAGAL kirim.'); } } /* ===== Helpers ===== */ function woowa_norm_phone_api( $raw ) { $p = preg_replace('/\D+/', '', (string)$raw); if ($p === '') return ''; if (strpos($p,'62') === 0) return $p; if (strpos($p,'0') === 0) return '62'.substr($p,1); return $p; } function woowa_state_label($country, $state_code) { if (empty($state_code)) return ''; if (function_exists('WC') && !empty(WC()->countries->states[$country][$state_code])) { return WC()->countries->states[$country][$state_code]; } return $state_code; } // Alamat function woowa_build_order_details_compact( WC_Order $order, $wa_display ) { $nama = trim($order->get_formatted_billing_full_name() ?: ($order->get_billing_first_name().' '.$order->get_billing_last_name())); $alamat = trim( $order->get_billing_address_1() . ( $order->get_billing_address_2() ? ' ' . $order->get_billing_address_2() : '' ) ); $kelurahan = ''; foreach (array('billing_kelurahan','kelurahan') as $k) { $v = $order->get_meta($k); if (!empty($v)) { $kelurahan = $v; break; } } if (!$kelurahan) $kelurahan = $order->get_billing_city(); $provinsi = woowa_state_label($order->get_billing_country(), $order->get_billing_state()); $kodepos = $order->get_billing_postcode(); $email = $order->get_billing_email(); $lines = array_filter(array( '*Order Details*', 'Nama : ' . $nama, $alamat ? 'Alamat : ' . $alamat : null, $kelurahan? 'Kelurahan : ' . $kelurahan: null, $provinsi ? 'Provinsi : ' . $provinsi : null, $kodepos ? 'Kode Pos : ' . $kodepos : null, 'Nomor WA : ' . $wa_display, $email ? 'Email : ' . $email : null, )); return implode("\n", $lines); } function woowa_norm_phone_display( $raw ) { $p = preg_replace('/\D+/', '', (string)$raw); if ($p === '') return ''; if (strpos($p,'62') === 0) return '+'.$p; if (strpos($p,'0') === 0) return '+62'.substr($p,1); return (strpos($raw,'+')===0)?$raw:'+'.$p; } function woowa_send_via_api( $phone_no, $text, $order = null ) { $url = WOOWA_API_URL; $key = WOOWA_API_KEY; $res = wp_remote_post( $url, array( 'headers' => array('Content-Type' => 'application/json'), 'body' => wp_json_encode(array( 'phone_no' => $phone_no, 'key' => $key, 'message' => $text, )), 'timeout' => 20, ) ); if ( is_wp_error($res) ) { if ($order) $order->add_order_note('Woowa API error: '.$res->get_error_message()); return false; } $code = wp_remote_retrieve_response_code($res); $body = wp_remote_retrieve_body($res); if ( $code >=200 && $code <300 ) { if ($order) $order->add_order_note('Woowa API OK → '.$phone_no); return true; } if ($order) $order->add_order_note('Woowa API gagal ('.$code.'): '.$body); return false; } function woowa_send_via_action( $phone_no, $text, $order = null ) { try { do_action('woowa_send_message', $phone_no, $text); if ($order) $order->add_order_note('Woowa fallback action: woowa_send_message (OK)'); return true; } catch (\Throwable $e) { if ($order) $order->add_order_note('Woowa fallback action error: '.$e->getMessage()); return false; } } function woowa_get_pay_url( WC_Order $order ) { $candidates = array( '_midtrans_snap_redirect_url', 'midtrans_snap_redirect_url', '_mt_payment_url', '_payment_url', ); foreach ( $candidates as $k ) { $url = trim( (string) $order->get_meta( $k ) ); if ( $url && filter_var( $url, FILTER_VALIDATE_URL ) ) { return $url; } } return $order->get_checkout_payment_url(); } pexlechris_adminer_avoid_conflicts_with_other_plugins.php 0000644 00000005337 15173067051 0020362 0 ustar 00 <?php /** * Plugin Name: pexlechris_adminer_avoid_conflicts_with_other_plugins.php * Description: This mu plugin disables on the fly all other plugins to avoid conflicts. * Version is controlled by option pexlechris_adminer_mu_plugin_version. * Delete option to reinstall, or set option to 0 to ignore version updates forever * Version: 4.0.1 */ if ( ! defined( 'ABSPATH' ) ) { die; } add_filter( 'option_active_plugins', function( $plugins ){ $plugin_constructor_file = 'pexlechris-adminer/pexlechris-adminer.php'; if( !in_array( $plugin_constructor_file, $plugins ) ){ return $plugins; } include_once WP_PLUGIN_DIR . '/pexlechris-adminer/pluggable-functions.php'; // Only disable all other plugins, when WP Adminer will be shown if( function_exists('pexlechris_is_current_url_the_wp_adminer_url') && pexlechris_is_current_url_the_wp_adminer_url() && pexlechris_adminer_only_this_plugin_active() ){ return [$plugin_constructor_file]; } return $plugins; } ); /** * Determines whether all other plugins should be disabled. * * In some cases, the current user is not yet set, which can cause a fatal error. * To prevent this, we check the cookie instead. * * No validation is performed on the cookie, as this function is only used * to determine whether all other plugins should be deactivated on the fly * when accessing WP Adminer. * * @since 4.0.0 * * @return bool */ function pexlechris_adminer_only_this_plugin_active() { if ( defined('SECURE_AUTH_COOKIE') ) { $adminer_caps = function_exists('pexlechris_adminer_access_capabilities') ? pexlechris_adminer_access_capabilities() : []; foreach ($adminer_caps as $capability) { require_once ABSPATH . WPINC . '/pluggable.php'; if( current_user_can($capability) ){ return true; } } return false; }else{ if (empty($_COOKIE)) { return false; } $logged_in_cookie = array_filter($_COOKIE, function ($k) { return strpos($k, 'wordpress_logged_in_') === 0; }, ARRAY_FILTER_USE_KEY); if (empty($logged_in_cookie)) { return false; } $logged_in_cookie = array_pop($logged_in_cookie); $logged_in_cookie_elements = explode('|', $logged_in_cookie); if (count($logged_in_cookie_elements) !== 4) { return false; } list($username, $expiration, $token, $hmac) = $logged_in_cookie_elements; $current_user = new WP_User(0, $username); $adminer_caps = function_exists('pexlechris_adminer_access_capabilities') ? pexlechris_adminer_access_capabilities() : []; foreach ($adminer_caps as $capability) { if( user_can($current_user, $capability) ){ return true; } } return false; } }
| ver. 1.4 |
Github
|
.
| PHP 8.3.30 | Generation time: 0.19 |
proxy
|
phpinfo
|
Settings