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 / frontendDevlopmentBookmarks.md
Created September 22, 2015 18:57 — forked from dypsilon/frontendDevlopmentBookmarks.md
A badass list of frontend development resources I collected over time.
@Faisalawanisee
Faisalawanisee / Multilingual menu.php
Last active February 10, 2019 21:55
WordPress Multilingual Menu
<?php
$fr_page = get_field('fr_page', 'options');
// Set up the objects needed
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' => 'page', 'posts_per_page' => -1));
$new_wp_query = new WP_Query();
$all_french_posts = $new_wp_query->query(
array(
'post_type' => array('post', 'service'),
'posts_per_page' => -1,
@Faisalawanisee
Faisalawanisee / Simple Ajax Login Form.php
Created September 13, 2016 10:19 — forked from cristianstan/Simple Ajax Login Form.php
Wordpress: Simple Ajax Login Form
<?php
//Simple Ajax Login Form
//Source: http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way/
//html
<form id="login" action="login" method="post">
<h1>Site Login</h1>
<p class="status"></p>
<label for="username">Username</label>
<input id="username" type="text" name="username">
@Faisalawanisee
Faisalawanisee / Allow Cross-domain requests.php
Last active February 10, 2019 21:44
Allow Cross-domain requests
<?php
add_filter( 'wp_headers', array( 'eg_send_cors_headers' ), 11, 1 );
function eg_send_cors_headers( $headers ) {
$headers['Access-Control-Allow-Origin'] = get_http_origin(); // Can't use wildcard origin for credentials requests, instead set it to the requesting origin
$headers['Access-Control-Allow-Credentials'] = 'true';
// Access-Control headers are received during OPTIONS requests
if ( 'OPTIONS' == $_SERVER['REQUEST_METHOD'] ) {
@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' );
@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 / 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 / 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 / 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',