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
| /* In order to use SESSION with AJAX etc in Wordpress. you must use add_action to hook into 'wp' */ | |
| add_action('wp', 'rk_start_session'); | |
| function rk_start_session() { | |
| global $post; | |
| //if you want to use anything from the $post variable you can | |
| if(!session_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
| /* To disable the Gutenberg editor sitewide, | |
| add the following snippet to functions.php or | |
| any other PHP file that has been included in functions.php */ | |
| add_filter('use_block_editor_for_post', '__return_false', 10); |
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 | |
| /*———— -Determine environment and load the corresponding config file- ————*/ | |
| //builds RegEx patterns with any number of optional hostnames | |
| function host_pattern($carry, $item, $initial){ | |
| return $carry . '(' . preg_quote($item) . ')?'; | |
| } | |
| $local_hosts = [ | |
| '.docker', |
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
| //dom_utils Class, keep this in a utils file of some sort | |
| class dom_utils { | |
| constructor(selector) { | |
| this.node = selector; | |
| } | |
| exists() { | |
| return typeof this.node !== 'undefined'; | |
| } |
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 | |
| /*Template Name: Some Template */ | |
| ?> |
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
| getSiblings(elem) { | |
| var siblings = []; | |
| var sibling = elem.parentNode.firstChild; | |
| for (; sibling; sibling = sibling.nextSibling) { | |
| if (sibling.nodeType !== 1 || sibling === elem) continue; | |
| siblings.push(sibling); | |
| } | |
| return siblings; | |
| } |
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 | |
| $upload_dir = wp_upload_dir(); | |
| $custom_files_path = $upload_dir['baseurl'] . '/files/'; | |
| //...continued | |
| ?> |
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
| "Include Media Breakpoint": { | |
| "prefix": "media", | |
| "body": [ | |
| "@include media('${1|>=,<=,>,<|}${2|480px,768px,1024px,1170px|}') {", | |
| "\t$0", | |
| "}", | |
| ], | |
| "description": "@include-media plugin sccs breakpoint" | |
| }, |
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
| copyToClipboard(str) { | |
| /* ——— Derived from: https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f | |
| improved to add iOS device compatibility——— */ | |
| const el = document.createElement('textarea'); // Create a <textarea> element | |
| let storeContentEditable = el.contentEditable; | |
| let storeReadOnly = el.readOnly; | |
| el.value = str; // Set its value to the string that you want copied | |
| el.contentEditable = 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 | |
| get_header(); | |
| $cat_id = get_queried_object_id(); | |
| $is_category = is_category($cat_id); | |
| $query_cat_id = $is_category ? $cat_id : null; | |
| $cat_data = get_category($cat_id); | |
| $post_id = $is_category ? $cat_id : get_option('page_for_posts'); | |
| //means-- if it's a category, set the ID to that category page so we can get its title etc. |