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 | |
| /** | |
| * Allow sorting orders screen by purchased product | |
| * Modified version of https://github.com/wp-plugins/woocommerce-filter-orders-by-product/blob/master/woocommerce-filter-orders-by-product.php | |
| */ | |
| if ( function_exists('WC') && is_admin() ): | |
| add_action( 'restrict_manage_posts', 'aa_product_filter_in_order', 50 ); | |
| add_filter( 'posts_where' , 'aa_product_filter_where' ); | |
| endif; |
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 | |
| /* | |
| If the user does not have permission to edit pages, restrict the media uploader to only show their own uploads. | |
| */ | |
| function rs_restrict_media_attachments_to_original_author( $media_query = array() ) { | |
| if ( !current_user_can( 'edit_pages' ) ) { | |
| $media_query['author'] = get_current_user_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 | |
| /* | |
| How to add Instagram (or other social media icons) to Divi's theme options. | |
| Step 1) | |
| Add the following function to your child theme's functions.php. | |
| This will add Instagram icon below the Google icon in the theme options. | |
| You can copy/paste the icon/url fields here to add more social networks. | |
| */ |
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 | |
| /** | |
| * Return the user_id who submitted an entry. | |
| * If the user was not logged in, but created an account | |
| * through the form, returns the created user ID instead. | |
| * | |
| * @param $entry_id | |
| * | |
| * @return int|false User ID or FALSE |
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 | |
| /* | |
| This code will let you have a page template in your plugin, and show that template in the "Page Templates" dropdown. | |
| It can also work for other post type templates, just change the filter "theme_page_templates" as needed. | |
| WP 4.7 only. | |
| Setup: | |
| 1. Replace "cppt" with your own plugin prefix. | |
| 2. Replace custom_plugin_page_template.php with whatever made-up template name you want. | |
| 3. Replace templates/custom-template.php with the real template (and directory) you want to load. |
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 | |
| // CSS is also needed, seen below. replace $breakpoint_medium with pixel value if necessary | |
| // [full_width](your content)[/full_width] | |
| function rs_shortcode_screen( $atts, $content = '' ) { | |
| $type = isset($atts['type']) ? $atts['type'] : false; | |
| if ( $type !== 'desktop' && $type !== 'mobile' ) { | |
| if ( current_user_can('edit_posts') ) { | |
| return '<strong>Shortcode "screen" error:</strong> You must provide the option type with a value of either desktop or mobile. For example, [screen type="desktop"]<em>your content</em>[/screen].'; |
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
| // Run this in your JS console on the UPS settings page for a each shipping zone | |
| var boxes = [{}]; // Your box data here. See: https://docs.google.com/spreadsheets/d/1S9kjnYRSq6DMRi1w_TVYOr-Ss7i1_ATJUarRt9Go-t8/edit?usp=sharing | |
| var $packing = jQuery('#packing_options'); | |
| var $add_box_button = $packing.find('.button.insert'); | |
| var $box_list = jQuery('#rates'); | |
| var currentbox = 0; | |
| var addBoxInterval = false; |
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 | |
| /* | |
| Solution based on a Stack Overflow answer by patrickzdb: | |
| https://stackoverflow.com/a/24514985/470480 | |
| Tax query solution for hidden products based on a WordPress Stack Exchange answer by kalle: | |
| https://wordpress.stackexchange.com/a/262628/19105 | |
| Please note: | |
| This file includes two functions/filters. |
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 | |
| // EXAMPLE USE IN COMMENTS | |
| /** | |
| * Convert current page number and the total number of pages into a number range for pagination. | |
| * Use $edge_number_count to indicate how many numbers should appear to the left or right of the current page. | |
| * If the start or end page is one off of the start or end of the entire set, the range is extended. This prevents page 2 from being the start page, and page N-1 from the end page. | |
| * | |
| * @param $current_page |