This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Real-time stock sync between WooCommerce stores via REST API webhooks. | |
| * | |
| * Store A sends stock updates when product stock changes. | |
| * Store B receives and applies the stock update. | |
| * Requires a shared SYNC_API_KEY constant defined in wp-config.php. | |
| */ | |
| // Store A: Send stock update when product stock changes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * BuddyPress Group Extension: Resources Tab | |
| * | |
| * Adds a custom "Resources" tab to BuddyPress groups using | |
| * the BP_Group_Extension API. Group admins can add resource | |
| * links via the settings screen; all members see the list. | |
| */ | |
| class My_Group_Resources extends BP_Group_Extension { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * WordPress Salt Keys in wp-config.php | |
| * | |
| * Salt keys encrypt session cookies. Get fresh keys from: | |
| * https://api.wordpress.org/secret-key/1.1/salt/ | |
| * | |
| * Regenerate after any suspected breach, after removing | |
| * a compromised admin user, or quarterly for high-value sites. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'wp_abilities_api_init', function() { | |
| wp_register_ability( 'my-bp-plugin/list-inactive-members', array( | |
| 'label' => 'List Inactive Members', | |
| 'description' => 'Retrieve community members with no activity in the specified number of days.', | |
| 'input_schema' => array( | |
| 'type' => 'object', | |
| 'properties' => array( | |
| 'days_inactive' => array( | |
| 'type' => 'integer', | |
| 'description' => 'Number of days of inactivity', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // BAD: N+1 pattern — fires a query per member | |
| $members = bp_core_get_users( array( 'per_page' => 20 ) ); | |
| foreach ( $members['users'] as $member ) { | |
| // Each call fires a SELECT against bp_xprofile_data | |
| $location = xprofile_get_field_data( 'Location', $member->ID ); | |
| $job_title = xprofile_get_field_data( 'Job Title', $member->ID ); | |
| $company = xprofile_get_field_data( 'Company', $member->ID ); | |
| echo "<div class='member-card'>"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Debian/Ubuntu | |
| sudo apt install imagemagick webp libavif-bin jpegoptim optipng | |
| # CentOS/RHEL/AlmaLinux | |
| sudo dnf install ImageMagick libwebp-tools libavif-tools jpegoptim optipng | |
| # macOS (Homebrew) | |
| brew install imagemagick webp libavif jpegoptim optipng |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| clamp(minimum, preferred, maximum) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://yourdomain.com/wp-admin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| This content is exclusively available to [membership_level] members. | |
| Unlock full access to our premium tutorials, downloads, and | |
| community features by joining today. | |
| [pmpro_button level="2" text="Become a Premium Member"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'eddc_calc_commission_amount', 'custom_tiered_commission', 10, 5 ); | |
| function custom_tiered_commission( $commission, $download_id, $price, $payment_id, $user_id ) { | |
| // Get vendor's total sales count | |
| $sales_count = eddc_count_vendor_sales( $user_id ); | |
| if ( $sales_count > 200 ) { | |
| $rate = 0.80; // 80% for top vendors | |
| } elseif ( $sales_count > 50 ) { | |
| $rate = 0.70; // 70% for established vendors | |
| } else { |