Skip to content

Instantly share code, notes, and snippets.

@ganmahmud
ganmahmud / excel2post.php
Created December 25, 2018 06:37
Excel file (.csv) to WP post Plugin
<?php
add_action('admin_menu', 'excel2post_plugin_setup_menu');
function excel2post_plugin_setup_menu(){
add_menu_page('Shoppers Mag CSV Import Page', 'Shoppers Mag CSV Import', 'manage_options', 'csv-import', 'e2p', "dashicons-image-rotate-right", 2);
}
function e2p(){
@hereswhatidid
hereswhatidid / custom-package-name.php
Created October 18, 2016 13:48
Create custom shipping packages and manually set their display names in WooCommerce
<?php
add_filter( 'woocommerce_shipping_package_name', 'rmg_package_names', 10, 3 );
function rmg_package_names( $package_name, $i, $package ) {
if ( ! empty( $package['name'] ) ) {
$package_name = $package['name'];
}
<?php
$db_con = mysqli_connect("localhost", "username", "password", "database");
$result = $db_con->query('SELECT * FROM some_table');
if (!$result) die('Couldn\'t fetch records');
$num_fields = mysqli_num_fields($result);
$headers = array();
while ($fieldinfo = mysqli_fetch_field($result)) {
$headers[] = $fieldinfo->name;
}
$fp = fopen('php://output', 'w');
@anchetaWern
anchetaWern / php-webscraping.md
Created August 4, 2013 13:18
web scraping in php

Have you ever wanted to get a specific data from another website but there's no API available for it? That's where Web Scraping comes in, if the data is not made available by the website we can just scrape it from the website itself.

But before we dive in let us first define what web scraping is. According to Wikipedia:

{% blockquote %} Web scraping (web harvesting or web data extraction) is a computer software technique of extracting information from websites. Usually, such software programs simulate human exploration of the World Wide Web by either implementing low-level Hypertext Transfer Protocol (HTTP), or embedding a fully-fledged web browser, such as Internet Explorer or Mozilla Firefox. {% endblockquote %}