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 | |
| namespace JensSogaard; | |
| class BlockHelper | |
| { | |
| /** | |
| * Gets ACF fields for a specific block on a given post | |
| * @author Jens Soegaard <[email protected]> | |
| */ | |
| public function getBlockFromPage(string $block_id, int $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 | |
| add_filter( 'nav_menu_link_attributes','cameronjonesweb_move_custom_menu_item_class_to_anchor_element', 10, 4 ); | |
| add_filter( 'nav_menu_css_class', 'cameronjonesweb_remove_custom_menu_item_class_from_li_element', 10, 4 ); | |
| /** | |
| * Get the custom item menu classes and add them to the anchor element | |
| * | |
| * @link https://cameronjonesweb.com.au/blog/how-to-move-the-custom-menu-item-classes-to-the-anchor-element/ | |
| * @param array $atts The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored. |
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
| /** | |
| * Only show current vendor's media in the media library | |
| * @param array $request Default request arguments | |
| * @return array Modified request arguments | |
| */ | |
| add_filter( 'request', 'pv_restrict_media_library', 10, 1 ); | |
| function pv_restrict_media_library( $request = array() ) { | |
| if( ! is_admin() ) { | |
| return $request; |
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 | |
| $iccProfile = '../path_to_icc/Profile.icc'; | |
| $image = new Imagick(); | |
| $image->clear(); | |
| $image->readImage($imagePath); | |
| if ($image->getImageColorspace() == Imagick::COLORSPACE_CMYK) { | |
| return; | |
| } | |
| $iccCmyk = file_get_contents($iccProfile); |
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( 'gform_field_css_class', 'cameronjonesweb_add_field_type_to_class', 10, 3 ); | |
| /** | |
| * Adds a class that defines the type of field to the li element in Gravity Forms | |
| * | |
| * @param string $css_class The existing CSS classes. | |
| * @param GF_Field $field The field object. | |
| * @param array $form The form object. | |
| * @return string |
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
| shopt -s globstar | |
| for i in **; do | |
| if [ -d "$i" ]; then | |
| # update this line to include directories to ignore | |
| if [[ "${i##/*}" != *"node_modules"* && "${i##/*}" != *"bower_components"* ]]; then | |
| if [ ! -f "${i##/*}/index.php" ]; then | |
| printf "Creating index file in %s\n" "${i##/*}" | |
| printf "<?php\n// Silence is golden." > ${i##/*}/index.php | |
| fi | |
| fi |
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
| public function filter_post_type_by_taxonomy( $post_type, $which ) { | |
| if ( 'my_post_type' == $post_type ) { | |
| $taxonomy = get_taxonomy( 'my_taxonomy' ); | |
| if ( $taxonomy ) { | |
| // Retrieve taxonomy terms | |
| $terms = get_terms( $taxonomy->name ); | |
| // Display filter HTML | |
| echo "<select name='{$taxonomy->name}' id='{$taxonomy->name}' class='postform'>"; | |
| echo '<option value="">' . sprintf( esc_html__( 'Show All %s', 'text-domain' ), $taxonomy->labels->name ) . '</option>'; |
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 | |
| /** | |
| * Create new user. | |
| * | |
| * @todo remove `prefix_` with your own slug. | |
| * | |
| * @since 1.0.0 | |
| */ | |
| if( ! function_exists( 'prefix_add_new_user' ) ) : | |
| function prefix_add_new_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 | |
| $ids = array(18821,18811,18817,18805,18807,18777,18774,18775); | |
| foreach ($ids as $key => $id) { | |
| $my_post = array( | |
| 'ID' => $id, | |
| 'tax_input' => array( | |
| '<taxonomy-name>' => array( `<tax-id1>`, `<tax-id2>`, `<tax-id-n` ), | |
| ), |
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: Enable/Disable plugins when doing local dev | |
| Plugin URL: https://gist.github.com/pbiron/52bb63042cf220256ece89bc07fb57b0 | |
| Description: If the WP_LOCAL_DEV constant is true, enables/disables plugins that you specify | |
| Version: 0.1 | |
| License: GPL version 2 or any later version | |
| Author: Paul V. Biron/Sparrow Hawk Computing | |
| Author URI: https://sparrowhawkcomputing.com | |
| */ |