Skip to content

Instantly share code, notes, and snippets.

@fomigo
fomigo / wp-localhost-ftp.php
Last active August 29, 2015 13:57
wp: FTP on localhost
<?php
// Add in wp-config.php
define('FS_METHOD', 'direct');
define('WP_HTTP_BLOCK_EXTERNAL', true);
/* from console
$ cd /var/www/
$ sudo chown -R www-data:www-data wordpress
@fomigo
fomigo / simple-hooks.php
Created April 1, 2014 16:00
wp: hooks simple implementation
<?php
$actions = array();
function add_action($hook, $function) {
global $actions;
if (! isset($actions[$hook]))
$actions[$hook] = array();
@fomigo
fomigo / wp-single-id-template
Created May 31, 2014 16:42
wp: single-{id}.php
<?php
function my_single_template_by_post_id( $located_template ) {
return locate_template( array( sprintf( "single-%d.php", absint( get_the_ID() ) ), $located_template ) );
}
add_filter( 'single_template', 'my_single_template_by_post_id' );
@fomigo
fomigo / paging.php
Created August 20, 2014 08:36 — forked from sloped/paging.php
<?php
//Use this function to create pagingation links that are styleable with Twitter Bootstrap
function paging() {
global $wp_query;
$total_pages = $wp_query->max_num_pages;
if ($total_pages > 1){
$current_page = max(1, get_query_var('paged'));
jQuery(document).ready(function() {
jQuery("input, textarea").each(function() {
jQuery(this).data('holder', jQuery(this).attr('placeholder'));
jQuery(this).focusin(function() {
jQuery(this).attr('placeholder', '');
});
jQuery(this).focusout(function() {
jQuery(this).attr('placeholder', jQuery(this).data('holder'));
<?php
/**
* =========================
* defaultTemplateByParentTv
* =========================
*
* Plugin for modX Revolution
* Set default template for children of a ressource
*
* Author:
<h2>Resource Form</h2>
<p>[[+fi.error.error_message]]</p>
<form class="form" action="[[~[[*id]]]]" method="post">
<input name="nospam:blank" type="hidden" />
<input name="resource_id" type="hidden" value="[[+fi.id]]" />
<label for="parent">Parent: <span class="error">[[+fi.error.parent]]</span></label>
<input id="parent" name="parent:required" type="text" value="[[+fi.parent]]" />
<br/>
<?php
$month_arr = array('01' => 'Янв',
'02' => 'Фев',
'03' => 'Мар',
'04' => 'Апр',
'05' => 'Мая',
'06' => 'Июн',
'07' => 'Июл',
'08' => 'Авг',
'09' => 'Сен',
Snippet: [[SnippetName]]
Chunk: [[$ChunkName]]
System Setting: [[++SettingName]]
TV: [[*fieldName/TvName]]
Link tag: [[~PageId? &paramName=`value`]]
Placeholder: [[+PlaceholderName]]
<?php
@fomigo
fomigo / list_hooked_functions.php
Last active August 29, 2015 14:18
WP_list_hooked_functions
function list_hooked_functions($tag=false){
global $wp_filter;
if ($tag) {
$hook[$tag]=$wp_filter[$tag];
if (!is_array($hook[$tag])) {
trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
return;
}
}
else {