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
# column_name - column name filter by | |
# column_name_2 - column name to concat | |
# table_name - table name :) | |
SELECT column_name, | |
GROUP_CONCAT(DISTINCT column_name_2 SEPARATOR ',') | |
FROM table_name | |
GROUP BY column_name; |
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
/** | |
* Returns dimensions (width and height) of a given svg (by url) | |
* | |
* @param string $image_url | |
* @source https://stackoverflow.com/a/6532357/9214537 | |
* | |
* @return string | |
*/ | |
function get_svg_dimensions( string $image_url ): string { | |
$parsed_xml = simplexml_load_string( file_get_contents( $image_url ) ); |
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 | |
global $acf_recalc_settings; | |
// IMPORTANT: Customize these settings for your website. | |
$acf_recalc_settings = array( | |
// How many updates to do each page load. As of November 2018, Google's GeoLocation API limit is 100 per second. | |
'posts_per_run' => 16, | |
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 /* This function attaches the image to the post in the database, add it to functions.php */ | |
function insert_attachment($file_handler,$post_id,$setthumb='false') { | |
// check to make sure its a successful upload | |
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) __return_false(); | |
require_once(ABSPATH . "wp-admin" . '/includes/image.php'); | |
require_once(ABSPATH . "wp-admin" . '/includes/file.php'); | |
require_once(ABSPATH . "wp-admin" . '/includes/media.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 | |
/** | |
* Disable Theme Editor | |
* Source: http://guides.beanstalkapp.com/deployments/deploying-wordpress.html | |
*/ | |
function remove_editor_menu() { | |
remove_action('admin_menu', '_add_themes_utility_last', 101); | |
} |
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 | |
/** | |
* Gets all products by category ID | |
* Original source: https://wordpress.stackexchange.com/questions/143582/get-the-product-list-of-a-given-category-id | |
*/ | |
<ul class="relatedlinks"> | |
<?php | |
$args = [ | |
'post_type' => 'product', |
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 | |
/** | |
* SOURCE: https://stackoverflow.com/questions/52937409/create-programmatically-a-product-using-crud-methods-in-woocommerce-3 | |
*/ | |
/* THE CODE FUNCTION */ | |
// Custom function for product creation (For Woocommerce 3+ only) | |
function create_product( $args ){ | |
global $woocommerce; |
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 makeMultidimensionalArray(inputArray, arraysCount = 20, arrayLength = 1) { | |
return [...Array(arraysCount)] // Create an array with number of elements (default = 20) | |
.map((item, index) => { | |
return Array(arrayLength).fill(inputArray[index]) // Make an inner array with the length of "index" (default = 1) | |
}) | |
} |
NewerOlder