View crx-downloader.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 | |
if(isset($_POST["submit"])){ | |
if(isset($_POST["url"]) && filter_var($_POST["url"], FILTER_VALIDATE_URL)){ | |
//Get extension id | |
$pos = strrpos($_POST["url"], '/'); | |
$end = $pos === false ? $_POST["url"] : substr($_POST["url"], $pos + 1); | |
$id = substr($end, 0, strpos($end, "?")); | |
$durl = "https://clients2.google.com/service/update2/crx?response=redirect&x=id%3D".$id."%26uc&prodversion=32"; | |
//Simply get! | |
header("Location: $durl"); |
View editor-post-excerpt.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 | |
add_action( 'add_meta_boxes', array ( 'add_tinymce_to_excerpt', 'switch_boxes' ) ); | |
class add_tinymce_to_excerpt{ | |
public static function switch_boxes(){ | |
if ( ! post_type_supports( $GLOBALS['post']->post_type, 'excerpt' ) ){ | |
return; | |
} | |
remove_meta_box( 'postexcerpt', '', 'normal' ); | |
add_meta_box( 'postexcerpt2', 'Excerpt' , array ( __CLASS__, 'show' ), null, 'normal', 'core' ); | |
} |
View wp-sanitize-array.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 wp_sanitize_array( $input ) { | |
return array_map( function( $val ) { | |
return sanitize_text_field( $val ); | |
}, $input ); | |
} |
View get-image-from-url.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 | |
/* | |
* Method 1: use file_put_contents, but it disabled in many shared hosts | |
*/ | |
$url = "http://site.ltd/test-image.jpg"; | |
file_put_contents("/path/to/folder/" . basename($url), file_get_contents($url)); | |
/* |
View download-and-attach.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 | |
require_once(ABSPATH . 'wp-admin/includes/media.php'); | |
require_once(ABSPATH . 'wp-admin/includes/file.php'); | |
require_once(ABSPATH . 'wp-admin/includes/image.php'); | |
if(!function_exists('wp_get_current_user')) { | |
include(ABSPATH . "wp-includes/pluggable.php"); | |
} | |
$url = "http://xyz.ltd/filenam.png";//Just a sample | |
$file = array(); |
View check-it.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 | |
/* | |
* Method 1: use curl, it must return 200 for http return code | |
*/ | |
$ch = curl_init($url); | |
curl_setopt($ch, CURLOPT_NOBODY, true); | |
curl_exec($ch); | |
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
curl_close($ch); | |
if( $httpCode == 200 ){ echo "File exists"; } |
View excerpts-in-pages.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 | |
/** | |
* More parameters: | |
* @link http://codex.wordpress.org/Function_Reference/add_post_type_support | |
**/ | |
add_post_type_support( 'page', 'excerpt' ); |
View www-post-thumb.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 namespace GM\WWWPostThumbnail; | |
/** | |
* Plugin Name: WWW Post Thumbnail | |
* Description: Allow to use an external image url as featured image. | |
* Plugin URI: https://gist.github.com/Giuseppe-Mazzapica/928bc22e5f49a654cf7c | |
* Author: Giuseppe Mazzapica | |
* Author URI: https://github.com/Giuseppe-Mazzapica | |
* License: MIT | |
* Version: 0.1.0 | |
* |
View meta-exists.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 | |
/** | |
* @link https://developer.wordpress.org/reference/functions/get_post_meta/ | |
**/ | |
// Only for post types | |
if( get_post_meta( $post_id, '_meta_key', true ) ) { | |
// do something | |
} |
OlderNewer