A collection of resources to learn object-oriented programming and related concepts for PHP developers. Original Please see CONTRIBUTING for details and contribute. ;)
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 file_get_mime($filename) { | |
$extension = pathinfo($filename, PATHINFO_EXTENSION); | |
$mimes = array( | |
'audio/mp4' => 'm4a|f4a|f4b', | |
'audio/ogg' => 'oga|ogg', | |
'audio/&' => 'mid|midi|mp3|wav', | |
'application/javascript' => 'js|jsonp', |
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 | |
require dirname(__FILE__).'/wp-blog-header.php'; | |
$wpdb->query("DELETE FROM wp_terms WHERE term_id IN (SELECT term_id FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%')"); | |
$wpdb->query("DELETE FROM wp_term_taxonomy WHERE taxonomy LIKE 'pa_%'"); | |
$wpdb->query("DELETE FROM wp_term_relationships WHERE term_taxonomy_id not IN (SELECT term_taxonomy_id FROM wp_term_taxonomy)"); | |
$wpdb->query("DELETE FROM wp_term_relationships WHERE object_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))"); | |
$wpdb->query("DELETE FROM wp_postmeta WHERE post_id IN (SELECT ID FROM wp_posts WHERE post_type IN ('product','product_variation'))"); | |
$wpdb->query("DELETE FROM wp_posts WHERE post_type IN ('product','product_variation')"); |
In this lesson, we're going to learn about classes, how they're defined, how they're instantiated, and how those instances are used.
We'll be covering the following in this lesson:
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 | |
/* | |
1.- Create an App. | |
2.- Go to: https://developers.facebook.com/tools/explorer/ | |
+ Select your new created app on the right top. | |
+ Select "Get App Token" |
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
/*********************************************************************************************************************** | |
*********************************************************************************************************************** | |
* CONTENTS: | |
* Native Object | |
* Object Literal | |
* Basic Object | |
* Psuedo-Class | |
* Self Executing/Invoking Structure | |
* Lazy Function | |
* Module Pattern |
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 get_google_spreadsheet($key) { | |
$url = "https://spreadsheets.google.com/feeds/list/{$key}/od6/public/values"; | |
$google_sheet = file_get_contents($url); | |
$xml = simplexml_load_string($google_sheet); | |
$data = array(); | |
foreach($xml->entry as $entry) { | |
$row = array(); | |
// The fields are in the gsx: namespace, so we need to specify that to be able to access them through SimpleXML. |
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 | |
// Parsing this spreadsheet: https://spreadsheets.google.com/pub?key=0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc&hl=en&output=html | |
$url = 'http://spreadsheets.google.com/feeds/list/0Ah0xU81penP1dFNLWk5YMW41dkcwa1JNQXk3YUJoOXc/od6/public/values?alt=json'; | |
$file= file_get_contents($url); | |
$json = json_decode($file); | |
$rows = $json->{'feed'}->{'entry'}; | |
foreach($rows as $row) { | |
echo '<p>'; |
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
/** | |
* mm_register function. | |
* Register a new user. | |
* @access public | |
* @return User errors or user is logged in. | |
*/ | |
function mm_register() { | |
if(!is_user_logged_in()) { | |
if(!empty($_POST)) { |