Skip to content

Instantly share code, notes, and snippets.

@ayebare
ayebare / Yoast Plugin
Created September 27, 2017 15:52
using json
(function($, window, document) {
var CblocksPlugin = function() {
window.YoastSEO.app.registerPlugin( 'CblocksPlugin', { status: 'loading' } );
this.getData();
};
CblocksPlugin.prototype.getData = function() {
var _self = this;
@ayebare
ayebare / xml-cleaner.php
Last active May 10, 2017 07:13
Cleaning invalid characters in a list of xml files
<?php
$path_to_xmls = 'updated/problem-updated/*.{wxr,xml}';
$files = glob( $path_to_xmls, GLOB_BRACE );
foreach ( $files as $file ) {
echo "{$file} \n";
$path_to_file = $file;
$file_contents = file_get_contents( $path_to_file );
$file_contents = preg_replace( '/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', '', $file_contents );
@ayebare
ayebare / Sample-code
Created November 14, 2016 07:33
Searching text data
function is_text_col( $type ) {
foreach ( array( 'text', 'varchar' ) as $token ) {
if ( false !== strpos( $type, $token ) )
return true;
}
return false;
}