Skip to content

Instantly share code, notes, and snippets.

Avatar

hamed hamedmoody

View GitHub Profile
@hamedmoody
hamedmoody / WP_Query-Arguments.php
Created Sep 30, 2021
All argument for WP_Query class
View WP_Query-Arguments.php
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.github.io
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/4.9.4/src/wp-includes/query.php
*/
$args = array(
View wordpress_category_json_hierarchy.php
<?php
$args = [
'taxonomy' => 'category',
'hide_empty' => 0,
'parent' => 0
];
function _get_child_terms( $items ) {
foreach ( $items as $item ) {
View wp_mail_smtp.php
<?php
defined( 'ABSPATH' ) OR exit;
/**
* Plugin Name: (WCM) PHPMailer SMTP Settings
* Description: Enables SMTP servers, SSL/TSL authentication and SMTP settings.
* Allow less secure apps in: https://myaccount.google.com/u/2/lesssecureapps?pageId=none
*/
add_action( 'phpmailer_init', 'phpmailerSMTP' );
function phpmailerSMTP( $mail )
{
View fix-rtl-in-gutenbeg-color-picker.php
add_action( 'admin_head', function(){
if( ! is_rtl() ){
return;
}
?>
<style type="text/css">
.components-color-picker__saturation-white {
background: linear-gradient(480deg,#fff,hsla(0,0%,100%,0)) !important;
View wordpress-emergency-reset-password-via-new-admin-user.php
<?php
/**
* Upload to wp-content/mu-plugins/whichevernameyoulike.php
*/
$login = 'foobar'; # New username
$password = 'barbaz'; # Password for the new user
$email = 'you@example.com'; # Email address of the new user
$ip = '127.0.0.1'; # Insert your IP, http://google.com/search?&q=what%20is%20my%20ip
if ($_SERVER['REMOTE_ADDR'] === $ip) {
View wordpress-emergency-reset-password-mu-plugin.php
<?php
$user_id = 1; # Insert your user ID or simply 1 for the first user that was created
$user_pass = 'secret'; # Insert a new password
$ip = '127.0.0.1'; # Insert your IP
if ($_SERVER['REMOTE_ADDR'] === $ip) {
require_once(ABSPATH . WPINC . '/registration.php');
require_once(ABSPATH . WPINC . '/pluggable.php');
$user = wp_update_user(array(
'ID' => $user_id,
View wpcli-reset-password.sh
$ wp user update 1 --user_pass=$UP3RstrongP4$w0rd
View wordpress-emergency-reset-password.php
<?php
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
View Control-Back-Button-Broswser-And-Android.php
# Inform the target page, with a url hash, that it can't go back
<form action="page2.html#no-back" method="post" />
<input type="text" name="data" value="The data" />
<input type="submit" value="Send data" />
</form>
//Javascript
// It works without the History API, but will clutter up the history
var history_api = typeof history.pushState !== 'undefined'