- Strict type inference only. No
asassertions, noany, no!non-null assertions - No type annotations when inference works. Let TS infer return types, variable types
- Use
satisfiesoveraswhen type validation needed - ES modules only. No
require(), nodynamic import(), no conditional imports - Static imports at file top.
π΅
This file contains hidden or 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
| -- ALL SUBSCRIBERS WITH AN ORDER COMPLETED | |
| SELECT | |
| u.ID, um.meta_value AS user_role, COALESCE(COUNT(p.ID), 0) AS completed_orders | |
| FROM wp_users AS u JOIN wp_usermeta AS um ON u.ID = um.user_id | |
| LEFT JOIN wp_postmeta AS pm ON pm.meta_value = um.user_id | |
| LEFT JOIN wp_posts AS p ON p.ID = pm.post_id | |
| WHERE um.meta_key = 'wp_capabilities' | |
| AND um.meta_value LIKE '%subscriber%' | |
| AND um.meta_value NOT LIKE '%administrator%' | |
| AND pm.meta_key = '_customer_user' |
This file contains hidden or 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 // Don't use this line. | |
| /** | |
| * This function will connect wp_mail to your authenticated | |
| * SMTP server. This improves reliability of wp_mail, and | |
| * avoids many potential problems. | |
| * | |
| * For instructions on the use of this script, see: | |
| * https://www.butlerblog.com/2013/12/12/easy-smtp-email-wordpress-wp_mail/ | |
| * |
This file contains hidden or 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
| function onFormSubmit( e ) { | |
| const values = e.namedValues; | |
| //e.values is an array of form values | |
| const fecha = e.values[ 0 ]; | |
| const email = e.values[ 1 ]; | |
| //file is the template file, and you get it by ID | |
| const file = DriveApp.getFileById( | |
| 'FILE_ID' |
This file contains hidden or 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 | |
| // Add the custom columns to the book post type: | |
| add_filter( 'manage_book_posts_columns', 'set_custom_edit_book_columns' ); | |
| function set_custom_edit_book_columns($columns) { | |
| unset( $columns['author'] ); | |
| $columns['book_author'] = __( 'Author', 'your_text_domain' ); | |
| $columns['publisher'] = __( 'Publisher', 'your_text_domain' ); | |
| return $columns; |
This file contains hidden or 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 | |
| add_action( 'wp_enqueue_scripts', function() { | |
| // Register the script | |
| wp_register_script('ajax-script', get_template_directory_uri() . '/js/my-ajax-script.js', ['jquery']); | |
| // Localize the script with new data | |
| wp_localize_script('ajax-script', 'my_ajax_object', ['ajax_url' => admin_url( 'admin-ajax.php' )]); | |
| // Enqueued script with localized data. | |
| wp_enqueue_script('ajax-script'); | |
| }); |
This file contains hidden or 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 | |
| /** | |
| * @see http://stackoverflow.com/questions/40836144/php-how-to-get-images-from-instagram-without-api-access-token | |
| * You can use function file_get_conents instead wp_remote_get | |
| */ | |
| function get_instagram_images( $username, $limit = 100 ){ | |
| $profile_url = "https://www.instagram.com/$username/?__a=1"; | |
| $iteration_url = $profile_url; |
This file contains hidden or 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 | |
| function get_instagram_data( $url, $javascript_loop = 0, $timeout = 5 ) { | |
| $url = str_replace( "&", "&", urldecode(trim($url)) ); | |
| $cookie = tempnam ("/tmp", "CURLCOOKIE"); | |
| $ch = curl_init(); | |
| curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.3) Gecko/20041001 Firefox/0.10.1" ); | |
| curl_setopt( $ch, CURLOPT_URL, $url ); | |
| curl_setopt( $ch, CURLOPT_COOKIEJAR, $cookie ); |
This file contains hidden or 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 | |
| function switch_page_template() { | |
| global $post; | |
| // Checks if current post type is a page, rather than a post | |
| if (is_page()) | |
| { | |
| // Checks if page is parent, if yes, return | |
| if ($post->post_parent == 0) |
NewerOlder