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 | |
| /** | |
| * The public-facing functionality of the plugin. | |
| * | |
| * @link https://dualcon.ddns.net/ | |
| * @since 1.0.0 | |
| * | |
| * @package My_Wp_Tools | |
| * @subpackage My_Wp_Tools/public |
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 this to your `functions.php` or (preferably) to a plugin: | |
| function featured_products_orderby( $orderby, $query ) { | |
| global $wpdb; | |
| if ( 'featured_products' == $query->get( 'orderby' ) ) { | |
| $featured_product_ids = (array) wc_get_featured_product_ids(); | |
| if ( count( $featured_product_ids ) ) { | |
| $string_of_ids = '(' . implode( ',', $featured_product_ids ) . ')'; | |
| $orderby = "( {$wpdb->posts}.ID IN {$string_of_ids} ) " . $query->get( 'order' ); |
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 | |
| include 'wp-config.php'; | |
| ini_set( 'display_errors', 1 ); | |
| ini_set( 'display_startup_errors', 1 ); | |
| error_reporting( E_ALL ); | |
| $dir = dirname( __FILE__ ) . '/dump.sql'; | |
| echo "<h3>Backing up database to `<code>{$dir}</code>`</h3>"; |
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 | |
| /** | |
| * Plugin Name: REST API - Post list randomize | |
| * Description: Randomize the content list in REST API passing `orderby=rand` as parameter. | |
| * Version: 1.0.0 | |
| * Author: Felipe Elia | Codeable | |
| * Author URI: https://codeable.io/developers/felipe-elia?ref=qGTOJ | |
| */ | |
| /** |
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 | |
| /** | |
| * Função para exibir paginação | |
| * | |
| * @param WP_Query $query Query que deverá ser paginada. | |
| * @param integer $range Quantidade de páginas ao redor da página atual. | |
| * @param string $get_param Nome do parâmetro em `$_GET` com o número da página atual. | |
| * @return string HTML com a paginação | |
| */ | |
| function starter_pagination( $query = null, $range = 2, $get_param = null ) { |
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 | |
| /** | |
| * Usage example: `php -f fetch-from-wp-rest-api.php https://wordpress.org/support/wp-json/wp/v2/articles helphub-list` | |
| */ | |
| $first_page = file_get_contents( $argv[1] . '?per_page=100' ); | |
| $first_page_headers = parse_headers( $http_response_header ); | |
| $content = json_decode( $first_page, true ); | |
| for ( $i = 2; $i < $first_page_headers['X-WP-TotalPages']; $i++ ) { |
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 | |
| $locales = file_get_contents( 'https://api.wordpress.org/stats/locale/1.0/' ); | |
| $locales = json_decode( $locales, true ); | |
| arsort( $locales ); | |
| $others = ''; | |
| $index = 1; | |
| foreach ( $locales as $locale => $value ) { | |
| if ( 'Others' === $locale ) { | |
| $others = $value; |
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 submit_form_data( $confirmation, $form, $entry ) { | |
| ... | |
| /** | |
| * hold the form data that will be submitted to leap API | |
| */ | |
| $leap_form_data = []; |
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_filter( | |
| 'ep_prepare_meta_data', | |
| function ( $prepared_meta ) { | |
| foreach ( $prepared_meta as $key => $meta_val ) { | |
| // Remove empty meta fields. | |
| if ( empty( $key ) || empty( $meta_val ) || empty( $meta_val[0] ) ) { | |
| unset( $prepared_meta[ $key ] ); | |
| continue; | |
| } |