Skip to content

Instantly share code, notes, and snippets.

View Faisalawanisee's full-sized avatar
🎯
Focusing

Faisal Khalid Faisalawanisee

🎯
Focusing
View GitHub Profile
@Faisalawanisee
Faisalawanisee / WP CRUD
Created September 26, 2018 12:44
WP CRUD
<?php
add_action( 'admin_init', 'nic_fi_names_install_db');
function nic_fi_names_install_db() {
global $wpdb;
$table_name = $wpdb->prefix.'nic_fi_names';
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
@Faisalawanisee
Faisalawanisee / Engraving Source Code for Michael
Created August 27, 2018 09:28
Engraving Source Code for Michael - Just Replace "FORMID" with your form ID number and all is good to go.
<?php
add_filter('gform_pre_render_FORMID', 'populate_posts_FORMID');
function populate_posts_FORMID($form) {
?>
<script>
var flag = true;
var checkExist = setInterval(function () {
if (jQuery('form#gform_FORMID').hasClass('cart')) {
jQuery('.engraving_loader').remove();
<?php
$min_meta = $max_meta = [];
if(isset($_GET['min_date']) || $_GET['max_date']) {
if(isset($_GET['min_date'])) {
$min_meta = array(
'key' => 'min_date',
'value' => $_GET['min_date'],
'compare' => '='
@Faisalawanisee
Faisalawanisee / unzip.php
Created August 10, 2018 09:46 — forked from solepixel/unzip.php
When load balancers have set timeouts at 30 seconds, this script will process requests that may take longer than 30 seconds (up to 15 minutes) without causing a timeout.
<?php
$cmd = "zip -9prv content_backup.zip .";
$pipe = popen($cmd, 'r');
if (empty($pipe)) {
throw new Exception("Unable to open pipe for command '$cmd'");
}
stream_set_blocking($pipe, false);
echo "\n";
@Faisalawanisee
Faisalawanisee / activate-plugin.php
Created August 10, 2018 09:39 — forked from solepixel/activate-plugin.php
Originally design to activate Andrew Norcross's Airplane Mode plugin (https://github.com/norcross/airplane-mode), this little script will allow you to activate a plugin when the WordPress admin plugin screen cannot be loaded, for whatever reason.
<?php
/**
* This file will activate the Airplane Mode plugin if not already activated. This is helpful when you do not have internet connection and you're unable to reach the WP Admin Plugins page to activate the plugin.
*/
// get WP bootstrap
define('WP_USE_THEMES', false);
require(__DIR__ . '/wp/wp-blog-header.php');
@Faisalawanisee
Faisalawanisee / iso-639-1-codes.php
Created July 16, 2018 19:07 — forked from DimazzzZ/iso-639-1-codes.php
ISO 639-1 language codes array
<?php
$codes = [
'ab' => 'Abkhazian',
'aa' => 'Afar',
'af' => 'Afrikaans',
'ak' => 'Akan',
'sq' => 'Albanian',
'am' => 'Amharic',
'ar' => 'Arabic',
@Faisalawanisee
Faisalawanisee / Add custom capabilities to custom post type.php
Last active February 10, 2019 21:24
Add custom capabilities to custom post type
<?php
function charity_post_type_register() {
$labels = array(
'name' => __( 'Charities', 'text-domain' ),
'singular_name' => __( 'Charity', 'text-domain' ),
'add_new' => _x( 'Add New Charity', 'text-domain', 'text-domain' ),
'add_new_item' => __( 'Add New Charity', 'text-domain' ),
'edit_item' => __( 'Edit Charity', 'text-domain' ),
@Faisalawanisee
Faisalawanisee / add-custom-avatar.php
Last active February 10, 2019 21:29
WordPress Add Custom Avatar
<?php
function filter_get_avatar_url( $url, $user_id ) {
// make filter magic happen here...
$get_img = get_user_meta( $user_id, 'meta_key', true );
if($get_img){
return $get_img;
}
@Faisalawanisee
Faisalawanisee / example_post_status.php
Created January 16, 2018 10:35 — forked from franz-josef-kaiser/example_post_status.php
Add a custom post status for WP (custom) post types
<?php
// No, Thanks. Direct file access forbidden.
! defined( 'ABSPATH' ) AND exit;
// INIT
add_action( 'after_setup_theme', array( 'unavailable_post_status', 'init' ) );
class unavailable_post_status extends wp_custom_post_status
{
/**
@Faisalawanisee
Faisalawanisee / install.php
Created March 16, 2017 20:26
WordPress custom install script
<?php
/**
* WordPress custom install script.
*
* Drop-ins are advanced plugins in the wp-content directory that replace WordPress functionality when present.
*
* Language: nl
*
* if ( file_exists( WP_CONTENT_DIR . '/install.php' ) ) {
* require ( WP_CONTENT_DIR . '/install.php' );