View render_vue_from_string_ajax_call.js
This file contains 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
let el = Vue.compile(`<MuiIcon icon="${icon}" />`); | |
el = new Vue({ | |
components: { | |
MuiIcon | |
}, | |
vuetify, | |
render: el.render, | |
staticRenderFns: el.staticRenderFns | |
}).$mount(); | |
return el.$el.outerHTML; |
View distinct.php
This file contains 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 | |
/** | |
* @param array $array | |
* | |
* @return array | false | |
*/ | |
function distinct( array $arr ) { | |
if ( is_array( $arr ) ) { |
View webpack hot reload disable nuxt.js
This file contains 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
// Add this to nuxt.config.js | |
build: { | |
publicPath: '/zenith/', | |
analyze: false, | |
hotMiddleware : { | |
reload:false | |
}, | |
// watch: ['api', 'modules'], | |
extend(config, {isDev, isClient}) { |
View programatically_add_route_nuxt.js
This file contains 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
const { resolve } = require('path'); | |
module.exports = function() { | |
this.extendRoutes(routes => { | |
routes.push({ | |
name: 'admin', | |
path: '/admin', | |
component: resolve('./pages/index.vue') | |
}) |
View 404-redirect.js
This file contains 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
// Add this file to /middleware | |
export default function ({params, route, redirect}) { | |
if(route.matched.length === 0) { // route is not found, redirect to homepage | |
redirect('302', '/'); | |
} | |
} |
View Get list of taxonomies for CPT.php
This file contains 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( | |
'object_type' => array( 'hotels' ) | |
); | |
$output = 'names'; // or objects | |
$operator = 'and'; // 'and' or 'or' | |
$taxonomies = get_taxonomies( $args, $output, $operator ); | |
if ( $taxonomies ) { | |
foreach ( $taxonomies as $taxonomy ) { |
View search_by_sku.php
This file contains 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 sku, author, publisher and format to product search | |
*/ | |
// hook into wp pre_get_posts | |
add_action('pre_get_posts', 'woo_search_pre_get_posts'); | |
/** | |
* Add custom join and where statements to product search query |
View shortcode_method_4.php
This file contains 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 custom_shortcode_scripts() { | |
global $post; | |
if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, 'myshortcode') ) { | |
wp_enqueue_script( 'my-script'); | |
} | |
} | |
add_action( 'wp_enqueue_scripts', 'custom_shortcode_scripts'); |
View shortcode_method_3.php
This file contains 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 your_prefix_detect_shortcode() { | |
global $wp_query; | |
$posts = $wp_query->posts; | |
$pattern = get_shortcode_regex(); | |
foreach ($posts as $post){ | |
if ( preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ) | |
&& array_key_exists( 2, $matches ) |
NewerOlder