Skip to content

Instantly share code, notes, and snippets.

View yanknudtskov's full-sized avatar

Yan Knudtskov yanknudtskov

View GitHub Profile
@yanknudtskov
yanknudtskov / move-wp-content-folder.php
Created January 4, 2014 13:20
Move the Wordpress Content Folder This new, more easily accessible wp-content folder will be used instead of the one in the WordPress directory. This will mean you will lose access to the default themes. You can either manually move them to the new content directory or you can register the original wp-content folder using register_theme_director…
define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . 'path/to/wp-content' );
define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/path/to/wp-content' );
@yanknudtskov
yanknudtskov / move-wp-config.php
Created January 4, 2014 13:20
Move the Wordpress Configuration File
define('ABSPATH', dirname(__FILE__) . '/');
require_once(ABSPATH . '../path/to/wp-config.php');
@yanknudtskov
yanknudtskov / Disable Adminbar for all users except Admin.php
Created January 4, 2014 13:21
Disable Adminbar for all users except Admin
add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar()
{
if (!current_user_can('administrator') && !is_admin())
{
show_admin_bar(false);
}
}
http://www.designyourway.net/blog/resources/31-css-code-snippets-to-make-you-a-better-coder/
<ul class="box">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
ul.box {
@yanknudtskov
yanknudtskov / Search and replace in MySQL table.mysql
Created January 4, 2014 13:24
Search and replace in MySQL table
update table_name set field_name = replace(field, 'search_string', 'replace_string') where instr(field_name, 'search_string') > 0;
function the_slug() {
$post_data = get_post($post->ID, ARRAY_A);
$slug = $post_data['post_name'];
return $slug;
}
function get_attachment_icons($echo = false){
$sAttachmentString = "<div class='documentIconsWrapper'> \n";
if ( $files = get_children(array( //do only if there are attachments of these qualifications
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'numberposts' => -1,
'post_mime_type' => 'application/pdf', //MIME Type condition
))){
foreach( $files as $file ){ //setup array for more than one file attachment
$file_link = wp_get_attachment_url($file->ID); //get the url for linkage
@yanknudtskov
yanknudtskov / Automatically adjust div width.css
Created January 4, 2014 13:30
Automatically adjust div's width using CSS
.wrapper {
border: 1px solid black;
width: 400px;
display:table;
}
.left {
border: 1px solid green;
display: table-cell;
width: 100%;
}
add_action( 'init', 'child_manage_woocommerce_styles', 99 );
define( 'WOOCOMMERCE_USE_CSS', false );
/**
* Remove all WooCommerce scripts and styles
*
* @author WP Smith
* @since 1.0.0
*/