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 | |
/* | |
Plugin Name: Add Extra Comment Fields | |
Plugin URI: http://pmg.co/category/wordpress | |
Description: An example of how to add, save and edit extra comment fields in WordPress | |
Version: n/a | |
Author: Christopher Davis | |
Author URI: http://pmg.co/people/chris | |
License: MIT | |
*/ |
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
// | |
// _oo0oo_ | |
// o8888888o | |
// 88" . "88 | |
// (| -_- |) | |
// 0\ = /0 | |
// ___/`---'\___ | |
// .' \\| |// '. | |
// / \\||| : |||// \ | |
// / _||||| -:- |||||- \ |
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 | |
/** | |
* READING TIME | |
* | |
* Calculate an approximate reading-time for a post. | |
* | |
* @param string $content The content to be measured. | |
* @return integer Reading-time in seconds. | |
*/ | |
function reading_time( $content ) { |
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 | |
/** | |
* Analyse a string , grab Bandcamp links and replace them by embed player | |
* You may change the html code of the player in buildEmbed method | |
* | |
* @author Michael CAILLET <a href="https://mi-ca.ch">mi-ca.ch</a> | |
* @version 1.0 | |
* @uses $bc=new BandCampEmbed($string); | |
* echo $bc->getEmbededText(); | |
* // OR |
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 | |
/* | |
PHP Download Image Or File From URL | |
I’ll show you 3 php functions that download a particular file (ex: image,video,zip,pdf,doc,xls,etc) from a remote resource (via a valid URL) then save to your server. | |
Depending on your current php.ini settings, some functions may not work; therefore, let try which function is best for you. | |
Note: please ensure the folder you want to store the downloaded file is existed and has write permission for everyone or the web process. | |
Download file from URL with 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 | |
/* | |
Function to import image from URL to WordPress media library and assign to a post | |
@params | |
$post_id - The post ID for which you need to assign the uploaded image as featured image | |
$image_url - The external image URL which needs to be imported to WordPress media library | |
*/ | |
function import_featured_image_from_url( $post_id = '', $image_url ='' ) { | |
//Check both post_id and image_url is not empty | |
if($post_id == '' || $image_url == '') { |