REST API response format based on some of the best practices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Adds a team to all the repos in a Github organization. This is a tedious | |
* process in the UI. You'll need a newer version of node to run this (e.g 9+) | |
* because it uses async/await. | |
* | |
* Instructions: | |
* | |
* 1. Copy this file somewhere on your computer, e.g. ~/addteamrepos.js | |
* 2. Fill in the uppercase variables below with the right values | |
* 3. Run this file: `$ node ~/addteamrepos.js` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Common | |
{ | |
/*--------------------- $_GET & $_POST ----------------- START */ | |
/** | |
* Get $_GET content, array or array item in filtered way | |
* | |
* @param object $parameter could be array or array item |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Enqueue custom fonts using protocol relative URL. | |
* | |
* Syntax: wp_enqueue_style( $handle, $src, $deps, $ver, $media ); | |
* Ensure $handle is unique to prevent conflicts with plugins | |
* | |
* Note(s): The pipe (|) operator is used to load multiple typefaces in a single call. We also only load the weights we want * by comma seperating them, instead of loading every available weight. | |
*/ | |
function theme_prefix_fonts() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'acf/get_valid_field', 'change_post_content_type'); | |
function change_post_content_type( $field ) { | |
if($field['type'] == 'wysiwyg') { | |
$field['tabs'] = 'visual'; $field['toolbar'] = 'basic'; $field['media_upload'] = 0; | |
} | |
return $field; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(!function_exists('get_theme_file_uri')){ | |
function get_theme_file_uri( $file = '' ) { | |
$file = ltrim( $file, '/' ); | |
if ( empty( $file ) ) { | |
$url = get_stylesheet_directory_uri(); | |
} elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { | |
$url = get_stylesheet_directory_uri() . '/' . $file; | |
} else { | |
$url = get_template_directory_uri() . '/' . $file; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"il": "Adana", | |
"plaka": 1, | |
"ilceleri": [ | |
"Aladağ", | |
"Ceyhan", | |
"Çukurova", | |
"Feke", | |
"İmamoğlu", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Replace img tag with amp-img | |
* | |
* <amp-img src="[src]" | |
* width="[width]" | |
* height="[height]" | |
* layout="responsive" | |
* alt="[alt]"> | |
* </amp-img> |
Here's a 'simple' way to get the YouTube subscriber number from Google's Youtube API v3:
- Go to https://console.developers.google.com/apis/library
- Log in with your Google account.
- Next to the logo click on 'Project' and 'Create project'. Name it whatever you want and click on 'Create'.
- Wait until the project is created, the page will switch to it by itself, it will take a couple of seconds up to a minute. Once it's done it will be selected next to the logo.
- Once it's created and selected, click on 'Credentials' from the menu on the left.
- Click on 'Create Credentials' and choose 'API Key'. You can restrict it to specific IPs, or types of requests (website, android, ios etc.) if you want, it's safer that way.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require dirname(__FILE__).'/wp-blog-header.php'; | |
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')"); | |
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'"); | |
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)"); | |
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))"); | |
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))"); | |
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')"); |
NewerOlder