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 / 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 / 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 / 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 / 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 / README.md
Created September 22, 2015 18:29 — forked from hofmannsven/README.md
Notes on working with Laravel CLI
@Faisalawanisee
Faisalawanisee / Deregistering Custom Post Types.php
Last active February 10, 2019 21:56
Deregistering Custom Post Types
<?php
/**
* Deregister matching post types.
*/
function custom_unregister_theme_post_types() {
global $wp_post_types;
foreach( array( 'portfolio', 'gallery', 'team', 'testimonial', 'highlight' ) as $post_type ) {
if ( isset( $wp_post_types[ $post_type ] ) ) {
unset( $wp_post_types[ $post_type ] );
}
@Faisalawanisee
Faisalawanisee / open-graph-protocol-examples.html
Last active February 10, 2019 22:00
Open Graph Protocol Examples
<meta property="og:title" content="Full structured image property">
<meta property="og:site_name" content="Open Graph protocol examples">
<meta property="og:type" content="website">
<meta property="og:locale" content="en_US">
<link rel="canonical" href="http://examples.opengraphprotocol.us/image-url.html">
<meta property="og:url" content="http://examples.opengraphprotocol.us/image-url.html">
<meta property="og:image:url" content="http://examples.opengraphprotocol.us/media/images/50.png">
<meta property="og:image:secure_url" content="https://d72cgtgi6hvvl.cloudfront.net/media/images/50.png">
<meta property="og:image:width" content="50">
<meta property="og:image:height" content="50">
manage_{$post_type}_posts_columns
https://codex.wordpress.org/Plugin_API/Filter_Reference/manage_$post_type_posts_columns
manage_{$post_type}_posts_custom_column
https://codex.wordpress.org/Plugin_API/Action_Reference/manage_$post_type_posts_custom_column
add_filter( 'manage_book_posts_columns', 'set_custom_edit_book_columns' );
add_action( 'manage_book_posts_custom_column' , 'custom_book_column', 10, 2 );
function set_custom_edit_book_columns($columns) {
unset( $columns['author'] );
// Get The Page ID You Need
get_option( ‘woocommerce_shop_page_id’ );
get_option( ‘woocommerce_cart_page_id’ );
get_option( ‘woocommerce_checkout_page_id’ );
get_option( ‘woocommerce_pay_page_id’ );
get_option( ‘woocommerce_thanks_page_id’ );
get_option( ‘woocommerce_myaccount_page_id’ );
get_option( ‘woocommerce_edit_address_page_id’ );
get_option( ‘woocommerce_view_order_page_id’ );
get_option( ‘woocommerce_terms_page_id’ );