Skip to content

Instantly share code, notes, and snippets.

Svetoslav Marinov lordspace

Block or report user

Report or block lordspace

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lordspace
lordspace / gist:7853704
Created Dec 8, 2013
How to return JSON from a WordPress plugin without an external plugin
View gist:7853704
<?php
/*
Plugin Name: Orbisius Sample Code
Plugin URI: http://club.orbisius.com/products/
Description: Sample plugin to return JSON
Version: 1.0.0
Author: Svetoslav Marinov (Slavi)
Author URI: http://orbisius.com
License: GPL v2
*/
@lordspace
lordspace / gist:5175010
Created Mar 16, 2013
Removes an error message shown by Limit Login Attempts WordPress plugin. NN attemmpts remaining. We don't need to give info to the attacker. Making error null solves half of the problem. There is a wrapper with a red border which we will remove with : login_error_message_hide_empty_error_container
View gist:5175010
add_filter('login_head', create_function('$a', "wp_enqueue_script('jquery');"));
add_filter('login_errors', 'login_error_message');
add_action('login_footer', 'login_error_message_hide_empty_error_container');
/**
* Removes an error message shown by Limit Login Attempts plugin.
* NN attempts remaining. We don't need to give info to the attacker.
* Making error null solves half of the problem. There is a wrapper with
* a red border which we will remove with : login_error_message_hide_empty_error_container
*
@lordspace
lordspace / mandrill_email_test.php
Last active Nov 6, 2015
This is an sample php code that uses mandrill service to send emails. It uses PHPMailer. Here is an article how to do the setup: https://medium.com/@qsandbox/getting-started-with-mandrill-c2c3a6ba5c2a
View mandrill_email_test.php
<?php
// Author: Slavi Marinov | Orbisius.com & qSandbox.com
// 0) Read this article https://medium.com/@qsandbox/getting-started-with-mandrill-c2c3a6ba5c2a
// 1) Join Mandrill at http://mandrill.com/
// 2) Download PHPMailer from https://github.com/PHPMailer/PHPMailer
// Adapted example from: shared/PHPMailer-master/examples/mailing_list.phps
require_once 'shared/PHPMailer-master/class.phpmailer.php';
require_once 'shared/PHPMailer-master/class.smtp.php';
$message = "This is a test message prepared on: " . date( 'r' ) . " from " . $_SERVER['HTTP_HOST'] . ' ' . $_SERVER['REMOTE_ADDR'];
@lordspace
lordspace / load-assets.php
Created Oct 28, 2015
How to load WordPress assets and append last modified time so the browser loads them only when necessary.
View load-assets.php
// the vhost has this line to define the environment 'SetEnv DEV_ENV development'
$suffix = empty($_SERVER['DEV_ENV']) ? '.min' : '';
wp_register_style('my-awesome-plugin', plugins_url("/assets/main{$suffix}.css", __FILE__), false,
filemtime( plugin_dir_path( __FILE__ ) . "/assets/main{$suffix}.css" ) );
wp_enqueue_style('my-awesome-plugin');
wp_enqueue_script( 'jquery' );
wp_register_script( 'my-awesome-plugin', plugins_url("/assets/main{$suffix}.js", __FILE__), array('jquery', ),
filemtime( plugin_dir_path( __FILE__ ) . "/assets/main{$suffix}.js" ), true);
View orbisius-fb-open-graph-tags.php
<?php
/*
Plugin Name: Orbisius Facebook Share Image Preview Fix
Plugin URI: http://orbisius.com
Description: Makes sure that post's featured image is 1200x630 so facebook can use it as preview.
Version: 1.0.0
Author: Svetoslav Marinov (Slavi)
Author URI: http://club.orbisius.com/products/
*/
@lordspace
lordspace / zzz_sync.php
Created Dec 15, 2014
How to Sync Your Plugins with a Staging Server Using WP-CLI
View zzz_sync.php
<?php
/**
* This script allows you to sync plugins from development machine with staging/live servers.
* Author: Svetoslav Marinov (SLAVI) | http://orbisius.com
* (c) All Rights Reserved.
* (c) Dec 2014
* License: LGPL
* zzz_sync.php
*/
@lordspace
lordspace / Windows fake sendmail
Created Aug 26, 2014
This is php.ini I used to setup Fake Sendmail on Windows 8
View Windows fake sendmail
[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = admin+umob@domain.com
@lordspace
lordspace / ajax.php
Last active Aug 29, 2015
Example: How to Make an Ajax Request when Twitter Bootstrap Alert is Dismissed. More info on: http://slavi.ca/tutorials/make-ajax-request-twitter-bootstrap-alert-dismissed/
View ajax.php
<?php
echo 'Ok';
@lordspace
lordspace / dbg_act_log
Created Apr 23, 2014
Log plugin activation errors.
View dbg_act_log
<?php
// install it in mu-plugins
add_action('activated_plugin', 'dbg_log_error', 0, 2);
function dbg_log_error($plugin, $network_wide) {
if (ob_get_length() == 0) {
return ;
}
@lordspace
lordspace / jquery ui range slider
Created Feb 16, 2014
How to which slider has been dragged in a range slider of jQuery UI using it in WordPress plugin
View jquery ui range slider
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-core ' );
wp_enqueue_script( 'jquery-ui-slider' );
wp_register_style('my_jq_ui', '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/themes/base/jquery.ui.all.css', __FILE__, false);
wp_enqueue_style('my_jq_ui');
<div id="slider-range"></div>
You can’t perform that action at this time.