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 | |
//---------------------------- | |
// Old way of getting post and custom fields - Get fields inside the loop with get_post_meta() that has 2-3 parameters | |
//---------------------------- | |
$the_query = new WP_Query( $args ); | |
// Loop | |
if ( $the_query->have_posts() ) { | |
while ( $the_query->have_posts() ) { |
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
function get_post_metas( $post_id , $fields_array , $single ){ | |
$fields_array_data = array(); | |
if( is_array( $fields_array )){ | |
foreach( $fields_array as $key => $value){ | |
$fields_array_data[] = get_post_meta( $post_id, $value , $single ); | |
} | |
} | |
if( !is_array( $fields_array )){ | |
$fields_array_data[] = get_post_meta( $post_id, $fields_array , $single ); | |
} |
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 quick_cart_5_horus(){ | |
global $woocommerce; | |
$product_id = sanitize_text_field( $_POST['product_id'] ); | |
// Be sure cart is empty from previous add to cart | |
WC()->cart->empty_cart(); | |
// Addding the product by product ID | |
WC()->cart->add_to_cart( $product_id ); | |
// Getting the cart item key |
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 save_postdata( $post_id, $post, $update ) | |
{ | |
$meta_keys = array( | |
"location" => "text", | |
); | |
foreach( $meta_keys as $meta_key => $type ) | |
{ | |
if( isset( $_POST[ $meta_key ] ) ) |
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
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | |
chmod +x wp-cli.phar | |
sudo mv wp-cli.phar /usr/local/bin/wp | |
wp core install --url=example.com --title=QuickWP --admin_user=admin --admin_password=123456 [email protected] | |
wp scaffold child-theme twentysixteen-child --parent_theme=twentysixteen | |
npm install -g bower | |
cd wp-content/themes/twentysixteen-child/ | |
bower install --save datatables.net | |
bower install --save datatables.net-dt | |
wp core update |
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
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | |
chmod +x wp-cli.phar | |
sudo mv wp-cli.phar /usr/local/bin/wp | |
wp core install --url=example.com --title=QuickWP --admin_user=admin --admin_password=123456 [email protected] | |
wp scaffold child-theme twentysixteen-child --parent_theme=twentysixteen | |
wp plugin install woocommerce --activate |
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
# Recives hostname : batz-bar-taxi-coupons-4241432 | |
# returns: batz-bar-taxi-coupons | |
IFS='-' read -r -a host_name_array <<< "$(hostname)" | |
unset 'host_name_array[${#host_name_array[@]}-1]' | |
IFS=$'-'; echo "${host_name_array[*]}" ; |
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
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | |
chmod +x wp-cli.phar | |
sudo mv wp-cli.phar /usr/local/bin/wp | |
siteurl=$(hostname) | |
siteurl="${siteurl%-*}" | |
echo $siteurl | |
echo "${siteurl%-*}" | |
wp core install --url=example.com --title=QuickWP --admin_user=admin --admin_password=123456 [email protected] | |
wp scaffold child-theme twentyseventeen-child --parent_theme=twentyseventeen |
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
#turn workspace server on ( "RUN" button), paste this into c9 terminal, and hit "enter" | |
SETUP_PATH="setup.sh" | |
cat >$SETUP_PATH <<'EOF' | |
#!/bin/bash | |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | |
chmod +x wp-cli.phar | |
sudo mv wp-cli.phar /usr/local/bin/wp | |
wp core install --url=https://$C9_HOSTNAME --title=QuickWP --admin_user=admin --admin_password=123456 --admin_email=$C9_EMAIL | |
wp option update my_option '{"site_url": "bar"}' --format=json | |
wp theme install twentyseventeen |
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
$get = wp_remote_get( $fileurl ); | |
$mirror = wp_upload_bits( basename( $fileurl ), '', wp_remote_retrieve_body( $get ) ); | |
$attachment = [ | |
'post_status' => 'inherit', | |
'post_mime_type' => $mirror['type'], | |
'parent_id' => $this_post_id, | |
'post_title' => $file_title | |
]; | |
wp_insert_attachment( $attachment, $mirror['file'], $this_post_id ); |
OlderNewer