Skip to content

Instantly share code, notes, and snippets.

View dhaval-parekh's full-sized avatar

Dhaval Parekh dhaval-parekh

View GitHub Profile
@dhaval-parekh
dhaval-parekh / cookies-experiment-page.php
Last active September 25, 2023 13:31
Cookies Experiment Page
<?php
/**
* Cookies experiment.
*/
$expire_time = strtotime( '+30 days' );
$domain = $_SERVER['HTTP_HOST']; //parse_url( $_SERVER['HTTP_HOST'], PHP_URL_HOST );
$external_domain = 'example.com';
$cookies_data = [
[
@dhaval-parekh
dhaval-parekh / undefined-array-key-path.patch
Created October 4, 2022 07:07
FIx: Undefined array key “path” in class-change-wp-admin-login.php
Index: includes/class-change-wp-admin-login.php
===================================================================
--- includes/class-change-wp-admin-login.php (revision 2793845)
+++ includes/class-change-wp-admin-login.php (working copy)
@@ -283,7 +283,8 @@
wp_die( __( 'This feature is not enabled.', 'change-wp-admin-login' ) );
}
- $request = parse_url( $_SERVER['REQUEST_URI'] );
+ $request = parse_url( $_SERVER['REQUEST_URI'] );
@dhaval-parekh
dhaval-parekh / amp-eligible-post-type-test.php
Created March 31, 2022 08:24
AMP eligible post type test.
<?php
/**
* Plugin Name: AMP eligible post type test.
* Description: Plugin to test eligible post types for AMP
* Version: 0.1
*
* @wordpress-plugin
* @author Dhaval Parekh
*/
@dhaval-parekh
dhaval-parekh / filter_input_wrapper.php
Last active July 26, 2021 08:36
PHP: Wrapper of filter_input()
<?php
/**
* This method is an improved version of PHP's filter_input() and
* works well on PHP CLI as well which PHP default method does not.
* Also Provide support INPUT_REQUEST.
*
* Reference:
* - https://bugs.php.net/bug.php?id=49184
* - https://bugs.php.net/bug.php?id=54672
*
@dhaval-parekh
dhaval-parekh / wp-cleanup.sh
Created July 26, 2021 08:35
Shell script to cleanup WordPress site.
#!/usr/bin/env bash
plugin_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
function wp() {
wp_path=$(which wp)
php "$wp_path" $url_flag --allow-root "$@"
}
wp rewrite flush