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 | |
| $args = array( | |
| 'meta_query' => array( | |
| array( | |
| 'key' => 'my_date_field', | |
| 'value' => array('2022-01-01', '2022-12-31'), | |
| 'type' => 'DATE', | |
| 'compare' => 'BETWEEN', | |
| ), | |
| ), |
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 | |
| $args = array( | |
| 'meta_query' => array( | |
| array( | |
| 'key' => 'featured_post', | |
| 'value' => '1', | |
| 'compare' => '=', | |
| ), | |
| ), | |
| 'no_found_rows' => true, |
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 | |
| $args = array( | |
| 'meta_query' => array( | |
| array( | |
| 'key' => 'city_name', | |
| 'value' => array('New York City', 'London', 'San Francisco'), | |
| 'compare' => 'IN', | |
| ), | |
| ), | |
| ); |
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 | |
| $args = array( | |
| 'meta_query' => array( | |
| 'relation' => 'AND', | |
| array( | |
| 'key' => 'city_name', | |
| 'value' => array('New York City', 'London', 'San Francisco'), | |
| 'compare' => 'IN', | |
| ), | |
| array( |
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 to check if an email is disposable using multiple API services | |
| async function isDisposableEmail(email, ip = null) { | |
| try { | |
| // Construct API URLs with email and optionally IP for StopForumSpam | |
| const debounceUrl = `https://disposable.debounce.io/?email=${email}`; | |
| const verifyMailUrl = `https://verifymail.io/api/${email.split('@')[1]}?key=${process.env.VERIFYMAIL_API_KEY}`; | |
| const stopForumSpamUrl = `https://api.stopforumspam.org/api?email=${email}&json=true${ip ? `&ip=${ip}` : ""}`; | |
| // Make parallel requests to the APIs | |
| const [debounceResponse, verifyMailResponse, stopForumSpamResponse] = await Promise.all([ |
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
| import * as cheerio from 'cheerio' | |
| export async function getMetadata(url) { | |
| // Ensure the URL starts with http:// or https:// | |
| if (!url.startsWith('http://') && !url.startsWith('https://')) { | |
| url = `https://${url}`; | |
| } | |
| try { | |
| // Fetch the HTML content of the 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 | |
| //Record user's last login to custom meta | |
| add_action( 'wp_login', 'smartwp_capture_login_time', 10, 2 ); | |
| function smartwp_capture_login_time( $user_login, $user ) { | |
| update_user_meta( $user->ID, 'last_login', time() ); | |
| } | |
| //Register new custom column with last login time | |
| add_filter( 'manage_users_columns', 'smartwp_user_last_login_column' ); |
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 | |
| // Limit the comment length to 6000 characters and a minimum of 50 characters in WordPress for a specific post | |
| add_filter('preprocess_comment', 'smartwp_limit_comment_length'); | |
| function smartwp_limit_comment_length($comment) { | |
| // Specify the post ID where you want this function to run | |
| $specific_post_id = 123; // Replace 123 with your desired post ID | |
| // Check if the current post is the specific post we want to target | |
| if (get_the_ID() == $specific_post_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 | |
| // Checking if a WordPress plugin (works for admin or front end) | |
| if ( in_array( 'plugin-directory/main-plugin-file.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { | |
| // Plugin is active | |
| } |
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 | |
| // Checking if a WordPress plugin is active in the admin dashboard | |
| if ( is_plugin_active( 'plugin-directory/main-plugin-file.php' ) ) { | |
| // plugin is active | |
| } |
NewerOlder