Jetpack – stats_get_csv period parameter

While researching to answer this SO Question, stumbled upon this one, which gave me the final hint. I’ll reproduce the relevant part: Function get_stats_csv /plugins/jetpack/modules/stats.php The function get_stats_csv calls http://stats.wordpress.com/csv.php. If we visit this address, we get this response: Error: api_key is a required parameter. Required parameters: api_key, blog_id or blog_uri. Optional parameters: table, post_id, … Read more

file_exists() acting weird

You are using get_template_directory_uri(), that’s URL, not PATH. Instead use get_template_directory(), that’ll return PATH. Like: $csv = get_template_directory() . ‘/report/report.csv’;

Export User Info to CSV from Front End

Nevermind, I figured out a way to make it work. I just removed the need for a url altogether. Here’s what I did in case anybody else wants to know. I changed the link to an form input button: <form method=”post”> <input type=”submit” name=”bc_export” class=”btn btn-export” value=”Export Store List for ‘.$atts[‘value’].'” /> </form> And changed … Read more

Woocommerce – Hide “add to cart” on free products

Look at the beginning of the add to cart templates in WooCommerce. At the beginning there is a check to determine whether the product is purchasable. Inside the is_purchasable() method in the product class is a filter. By default the product is not purchasable if there is no price set at all, but that can … Read more

Allow CSV files to be uploaded

There’s a bug in WordPress 4.7-4.7.3 related to validating MIME types, so the code provided by Dave Romsey won’t work. There’s a plugin in the repo that will bypass MIME checks, but it disables the checks for all users and all extensions. I think a better way would be to add a new capability for … Read more

Creating 20,000 Posts or Pages using a .csv file?

Import posts from a .csv file with WP-CLI If our import.csv is tab delimited, with two columns: Planet Mars The red planet. Planet Earth Our blue planet. then we can parse it with help of this answer, where we use IFS=$’\t’ instead as tab delimiter: while IFS=$’\t’, read col1 col2; \ do \ echo “$col1|$col2”; … Read more

Export data as CSV in back end with proper HTTP headers

Do not point the URL to admin.php, use admin-post.php instead: ‘<a href=”‘ . admin_url( ‘admin-post.php?action=print.csv’ ) . ‘”>’ In your plugin register a callback for that action: add_action( ‘admin_post_print.csv’, ‘print_csv’ ); function print_csv() { if ( ! current_user_can( ‘manage_options’ ) ) return; header(‘Content-Type: application/csv’); header(‘Content-Disposition: attachment; filename=example.csv’); header(‘Pragma: no-cache’); // output the CSV data } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)