Skip to content

Instantly share code, notes, and snippets.

Avatar

gaupoit gaupoit

View GitHub Profile
@gaupoit
gaupoit / woocommerce_process_product_meta_simple.php
Created Jun 18, 2020
woocommerce_process_product_meta_simple usage sample
View woocommerce_process_product_meta_simple.php
<?php
add_action( 'woocommerce_process_product_meta_simple', 'save_options' );
function save_options( $product_id ) {
$keys = array(
'_ppwp_woo_protected_post',
'_ppwp_woo_usage_limit',
'_ppwp_woo_expiration',
'_ppwp_woo_custom_text',
'_ppwp_woo_protection_type',
@gaupoit
gaupoit / woocommerce_product_data_panels.php
Last active Jun 18, 2020
woocommerce_product_data_panels usage example
View woocommerce_product_data_panels.php
<?php
add_action( 'woocommerce_product_data_panels', 'show_ppwp_access_link_tab_content' );
function show_ppwp_access_link_tab_content() {
global $woocommerce, $post;
?>
<div id="ppwp_woo_options" class="panel woocommerce_options_panel">
<?php
woocommerce_wp_select(
array(
@gaupoit
gaupoit / woocommerce_product_data_tabs_filter.php
Created Jun 18, 2020
woocommerce_product_data_tabs filter usage
View woocommerce_product_data_tabs_filter.php
<?php
add_filter('woocommerce_product_data_tabs', 'add_ppwp_access_link_tab');
function add_ppwp_access_link_tab($tabs) {
$tabs['ppwp_woo'] = array(
'label' => 'PPWP Access Link',
'target' => 'ppwp_woo_options',
'class' => array( 'show_if_virtual' ),
'priority' => 65,
);
@gaupoit
gaupoit / integrate-swp.php
Last active Jun 14, 2020
Integrate PDA Gold with Simple WordPress Membership
View integrate-swp.php
<?php
add_filter( 'pda_before_handle_normal_fap', 'pda_handle_simple_membership', 10, 3 );
/**
* Callback to handle before checking FAP. This function will help to fix the problem
* when WordPress cookie expired before Simple WordPress Membership one.
*
* @param bool $is_valid_fap Flag to know whether FAP is valid.
* @param int $attachment_id The attachment ID.
* @param string $fap_type FAP type.
@gaupoit
gaupoit / sibling-passwords.php
Created Jun 9, 2020
Sibling Passwords Protection
View sibling-passwords.php
<?php
add_filter( 'ppwp_pro_check_valid_password', 'ppwp_pro_check_valid_sibling_password', 20, 2 );
/**
* Check valid sibling password.
*
* @param array $result The result after entering password including is_valid key.
* @param array $params The options passed from the hook including
* string password The password user entered.
View customize-entire-site-form-v2.php
<?php
add_filter( 'ppw_before_return_entire_site_form', 'custom_entire_site_form', 10, 2 );
/**
* Customize entire site login form with more options.
*
* @param string $form The current from in HTML string.
* @param array $options The form options including:
* string logo_content
* string password_label
@gaupoit
gaupoit / customize-entire-site.php
Last active Jun 8, 2020
Customize WordPress Password Form - Entire Site
View customize-entire-site.php
<?php
add_filter( 'ppw_custom_entire_site_login_form', 'custom_login_form' );
function custom_login_form() {
$is_wrong_password = isset( $_GET['action'] ) && $_GET['action'] === 'ppw_postpass' && isset( $_POST['input_wp_protect_password'] ) ? 'display: block' : 'display: none'; // Do not remove it. This helps to check whether the user entered password correctly.
return '
<div class="pda-form-login">
<!--Customize your own logo-->
@gaupoit
gaupoit / integrate-raw-url.php
Last active May 29, 2020
Integrate PDA Gold raw URL
View integrate-raw-url.php
<?php
add_filter( 'pda_after_filter_internal_url', 'ppwp_support_raw_internal_url', 10, 2 );
add_filter( 'ppwp_before_get_size_and_attachment_id_by_attachment_url', 'ppwp_get_raw_url_cb', 10, 2 );
add_filter( 'pda_token_urls_before_merge', 'ppwp_make_unique_token_urls', 10, 2 );
/**
* Support raw internal URLs when user enables raw URL option.
*
* @param array $filtered_urls Filtered URLs.
* @param array $urls Non-filtered URLs.
View ppf-form-action-url.php
<?php
add_filter( 'ppwp_ppf_action_url', 'ppwp_get_custom_ppf_action_url', 999, 1 );
/**
* Replace the default URL to current page.
*
* @param string $default_url The default URL.
*
* @return mixed
*/
@gaupoit
gaupoit / ppw-integrate-with-pro-photo7.php
Last active May 20, 2020
Integrate PPWP with Pro Photo 7 theme
View ppw-integrate-with-pro-photo7.php
<?php
add_filter( 'plugin_loaded', 'add_prophoto_middleware' );
function add_prophoto_middleware() {
add_action('pp_render_content', 'ppw_check_password_protection' );
add_action('wp', 'ppw_prevent_caching' );
}
function ppw_prevent_caching() {
global $post;