Skip to content

Instantly share code, notes, and snippets.

@wecodelaravel
wecodelaravel / wp-media-lib-size-col.php
Created May 7, 2019 01:31 — forked from hearvox/wp-media-lib-size-col.php
Add image data to new column to Media Library: file-size (bytes), image dimensions (pixels), and optional ratio between the two.
<?php
/* Add image data column to Media Library */
/**
* Add columns (file-size) to the Media Library list table.
*
* @param array $posts_columns Existing array of columns displayed in the Media list table.
* @return array Amended array of columns to be displayed in the Media list table.
*/
function my_media_columns( $posts_columns ) {
$posts_columns['size'] = __( 'Size', 'headecon' );
@wecodelaravel
wecodelaravel / wp-excerpt-char-count.php
Created May 7, 2019 01:31 — forked from hearvox/wp-excerpt-char-count.php
Add a Character Counter to Excerpt box in Edit Post screen (with suggested range).
<?php
/**
* Add a Character Counter to Excerpt box in Edit Post screen.
*
* Includes suggested range.
* Char-count number is color red when outside range and green within.
*
* @link http://wpsites.org/add-character-counter-excerpt-box-10503/
*/
function my_excerpt_count_js() {
<ol>
<?php
/* Remove duplicate meta, in this case Author and Contact (custom tax) */
// Get all posts assigned a term in a specific custom taxonomy.
$tax = 'contact';
$args = array(
'post_type' => 'post',
'posts_per_page' => 1000,
'orderby' => 'ID',
@wecodelaravel
wecodelaravel / wp-yoast-hooks.php
Created May 7, 2019 01:30 — forked from hearvox/wp-yoast-hooks.php
Hooks to disable Yoast SEO plugin features and admin screen controls.
<?php
/*******************************
=Yoast SEO Hooks (includes Premium)
******************************/
/* Remove default redirects feature, for posts and term.
* @link https://kb.yoast.com/kb/how-to-disable-automatic-redirects/
*/
add_filter('wpseo_premium_post_redirect_slug_change', '__return_true' );
add_filter('wpseo_premium_term_redirect_slug_change', '__return_true' );
@wecodelaravel
wecodelaravel / add-yoast-seo-data-to-WP-REST-API.php
Created May 7, 2019 01:29 — forked from ccurtin/add-yoast-seo-data-to-WP-REST-API.php
Add 'yoast' SEO data to the REST API w/ og & twitter meta fallbacks...
<?php
/*
Creates and end-point that get Yoast SEO meta tags...
*/
add_action('rest_api_init', 'add_yoast_data');
function add_yoast_data()
{
// Add your post types here...
register_rest_field(array(
<script type = 'application/ld+json' class = 'yoast-schema-graph yoast-schema-graph--main'> {
"@context": "https://schema.org",
"@graph": [{
"@type": "Organization",
"@id": "https://yoast.com/#organization",
"name": "Yoast",
"url": "https://yoast.com/",
"sameAs": ["https://www.facebook.com/yoast", "https://www.instagram.com/yoast/", "https://www.linkedin.com/company/1414157/", "https://www.youtube.com/yoast", "https://www.pinterest.com/yoast/", "https://en.wikipedia.org/wiki/Yoast", "https://twitter.com/yoast"],
"logo": {
"@type": "ImageObject",
<script type = 'application/ld+json' class = 'yoast-schema-graph yoast-schema-graph--main'> {
"@context": "https://schema.org",
"@graph": [{
"@type": "Organization",
"@id": "https://yoast.com/#organization",
"name": "Yoast",
"url": "https://yoast.com/",
"sameAs": ["https://www.facebook.com/yoast", "https://www.instagram.com/yoast/", "https://www.linkedin.com/company/1414157/", "https://www.youtube.com/yoast", "https://www.pinterest.com/yoast/", "https://en.wikipedia.org/wiki/Yoast", "https://twitter.com/yoast"],
"logo": {
"@type": "ImageObject",
@wecodelaravel
wecodelaravel / MediaVideoConverterListener.php
Created November 28, 2018 23:53 — forked from Nks/MediaVideoConverterListener.php
Laravel Media Library converting video to .mp4 after saving
<?php
namespace App\Listeners;
use App\Media;
use FFMpeg\FFMpeg;
use FFMpeg\Format\Video\X264;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\SerializesModels;
@wecodelaravel
wecodelaravel / MimeTypes.php
Created September 13, 2018 23:24 — forked from kongondo/MimeTypes.php
List of MimeTypes mapped to file extensions
<?php
// I made this array by joining all the following lists + .php extension which is missing in all of them.
// please contribute to this list to make it as accurate and complete as possible.
// https://gist.github.com/plasticbrain/3887245
// http://pastie.org/5668002
// http://pastebin.com/iuTy6K6d
// total: 1223 extensions as of 16 November 2015
$mime_types = array(
'3dm' => array('x-world/x-3dmf'),
'3dmf' => array('x-world/x-3dmf'),
@wecodelaravel
wecodelaravel / remote-file-copy.php
Created September 13, 2018 23:22 — forked from kongondo/remote-file-copy.php
Remote file copying with progress reporting in PHP.
<?php
/*
* Remote File Copy PHP Script 2.0.0
*
* Copyright 2012, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/