Skip to content

Instantly share code, notes, and snippets.

onst apiResponse = require('./tool/api-response');
const MESSAGE = require('./message/messages');
const UPDATE_OWNERSHIP = 'updateOwnership';
const PLANT = 'Plant';
const USER_TABLE = '_User';
const PLANT_FIELD = 'plant';
const PLANT_OWNERSHIP = 'PlantOwnership';
const OWNERSHIP_ROLE_FIELD = 'ownershipRole';
const OBJECT_ID = 'objectId';
const OWNERSHIP_ROLE = 'OwnershipRole';
@gaupoit
gaupoit / buildSchema.ts
Created May 11, 2021 03:53 — forked from Moumouls/buildSchema.ts
Static Schema for Parse Server (TS/JS) (tested, and production ready)
// This function update, migrate and create Classes
export const buildSchemas = async (localSchemas: any[]) => {
try {
const timeout = setTimeout(() => {
if (process.env.NODE_ENV === 'production') process.exit(1)
}, 20000)
const allCloudSchema = (await Parse.Schema.all()).filter(
(s: any) => !lib.isDefaultSchema(s.className),
)
clearTimeout(timeout)
@gaupoit
gaupoit / woocommerce_process_product_meta_simple.php
Created June 18, 2020 01:39
woocommerce_process_product_meta_simple usage sample
<?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 June 18, 2020 01:37
woocommerce_product_data_panels usage example
<?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 June 18, 2020 01:32
woocommerce_product_data_tabs filter usage
<?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 June 14, 2020 14:05
Integrate PDA Gold with Simple WordPress Membership
<?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 June 9, 2020 03:08
Sibling Passwords Protection
<?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.
@gaupoit
gaupoit / customize-entire-site-form-v2.php
Created June 8, 2020 04:23
Customize entire site form
<?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 June 8, 2020 03:30
Customize WordPress Password Form - Entire Site
<?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 02:24
Integrate PDA Gold raw URL
<?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.