Skip to content

Instantly share code, notes, and snippets.

View unsalkorkmaz's full-sized avatar

Ünsal Korkmaz unsalkorkmaz

View GitHub Profile
<?php
/**
* Set excerpt from ACF field
*/
add_action('acf/save_post', function($post_id) {
$post_excerpt = get_field( 'short_description', $post_id );
if ( ( !empty( $post_id ) ) AND ( $post_excerpt ) ) {
@jeromeetienne
jeromeetienne / multiline.js
Last active June 10, 2019 20:59
a snippet to have multi lines string in javascript.
var multilineString = (function(){ /*
this
is
a
multiline
string.
*/}).toString().split('\n').slice(1, -1).join('\n');
console.log(multilineString);
@markjaquith
markjaquith / wp-config.php
Created August 12, 2013 20:19
`wp-config.php` file to sit above a pristine WordPress directory, whereby the site can symlink their WP directory to a common one, and this file will make sure their `wp-config.php` is the one that gets called. Untested in production. Just an idea right now.
<?php
$path = str_replace( $_SERVER['DOCUMENT_ROOT'], '', dirname( $_SERVER['SCRIPT_FILENAME'] ) );
$path_parts = explode( '/', $path );
while ( count( $path_parts ) > 0 ) {
$path = $_SERVER['DOCUMENT_ROOT'] . implode( '/', $path_parts ) . '/wp-config.php';
if ( file_exists( $path ) ) {
include( $path );
break;
} else {
array_pop( $path_parts );
@r-a-y
r-a-y / gist:5578432
Last active July 23, 2020 06:55
Disable BuddyPress' registration and use WP's instead. Paste this in /wp-content/plugins/bp-custom.php.
/**
* Disables BuddyPress' registration process and fallsback to WordPress' one.
*/
function my_disable_bp_registration() {
remove_action( 'bp_init', 'bp_core_wpsignup_redirect' );
remove_action( 'bp_screens', 'bp_core_screen_signup' );
}
add_action( 'bp_loaded', 'my_disable_bp_registration' );
@ethitter
ethitter / gist:4430520
Last active May 31, 2017 16:14
WordPress MU Domain Mapping and the Customizer
Index: domain_mapping.php
===================================================================
--- domain_mapping.php (revision 688919)
+++ domain_mapping.php (working copy)
@@ -685,7 +685,7 @@
}
function redirect_to_mapped_domain() {
- global $current_blog, $wpdb;
+ global $current_blog, $wpdb, $wp_customize;
@thomaspark
thomaspark / subnav.css
Last active June 6, 2023 10:19
Subnav for Bootstrap 2
section {
padding-top: 60px;
}
.subnav {
margin-bottom: 60px;
width: 100%;
height: 36px;
background-color: #eeeeee; /* Old browsers */
background-repeat: repeat-x; /* Repeat the gradient */
@beck24
beck24 / script match
Created November 27, 2012 23:40
preg_match_all <script></script> match
<?php
$html = <<<HTML
<html>
<head>
<script src="http://example.com"></script>
</head>
<body>
<div>
<script>
@jaredatch
jaredatch / gist:3909892
Created October 18, 2012 04:42
create select from navigation
// Create the dropdown base
$("<select />").appendTo("nav");
// Create default option "Go to..."
$("<option />", {
"selected": "selected",
"value" : "",
"text" : "Go to..."
}).appendTo("nav select");