Skip to content

Instantly share code, notes, and snippets.

View robertstaddon's full-sized avatar

Robert Staddon robertstaddon

View GitHub Profile
@robertstaddon
robertstaddon / functions.php
Last active January 16, 2017 15:41
Remove Divi sidebar styling on BuddyPress / BBPress pages by removing body classes
<?php
add_filter('body_class', 'modify_body_classes', 20);
function modify_body_classes( $classes ) {
if( is_buddypress() || is_bbpress() ) {
$remove_classes = array('et_right_sidebar', 'et_left_sidebar', 'et_includes_sidebar');
foreach( $classes as $key => $value ) {
if ( in_array( $value, $remove_classes ) ) unset( $classes[$key] );
}
<?php
$confs = array(
$VAR->domain->physicalHosting->customConfigFile,
$VAR->domain->physicalHosting->customSslConfigFile
);
$documentRoot = '';
foreach ($confs as $conf) {
if (file_exists($conf)) {
$lines = file($conf);
foreach ($lines as $line) {
location /internal-nginx-static-location/ {
<?php if(!empty($documentRoot)): ?>
alias <?php echo $documentRoot; ?>/;
<?php else: ?>
alias <?php echo $OPT['documentRoot']; ?>/;
<?php endif; ?>
add_header X-Powered-By PleskLin;
internal;
}
DocumentRoot /var/www/vhosts/primarydomain.com/httpdocs
SuexecUserGroup primarydomainuser psacln
<Directory '/var/www/vhosts/primarydomain.com/httpdocs'>
AllowOverride All
</Directory>
<Directory /var/www/vhosts/primarydomain.com/httpdocs>
<IfModule mod_fcgid.c>
<Files ~ (\.fcgi)>
SetHandler fcgid-script
Options +FollowSymLinks +ExecCGI
</Files>
</IfModule>
<IfModule mod_fcgid.c>
<Files ~ (\.php)>
SetHandler fcgid-script
@robertstaddon
robertstaddon / rewrite.php
Created February 24, 2017 20:43
Rewrite POST data
<?php
if($_POST) {
$postdata = http_build_query($_POST);
$opts = array('http' =>array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
$context = stream_context_create($opts);
$result = file_get_contents("https://mynewdomain.com$_SERVER[REQUEST_URI]", false, $context);
echo $result;
} else {
header("Location: https://mynewdomain.com$_SERVER[REQUEST_URI]");
exit();
@robertstaddon
robertstaddon / functions.php
Created March 15, 2017 06:36
Hide category and forum menu items that are restricted by Itthinx Groups
<?php
/**
* Menu items of categories and forums should be hidden if the user doesn't belong to the Group
*/
if ( !is_admin() ) {
add_filter( 'wp_get_nav_menu_items', 'lenspiration_hide_groups_restricted_menu_items', 999, 3 );
}
function lenspiration_hide_groups_restricted_menu_items( $items = null, $menu = null, $args = null ) {
$user_id = get_current_user_id();
@robertstaddon
robertstaddon / functions.php
Last active August 14, 2017 21:20
Divi - custom featured post image size
<?php
function mycustom_featured_width( ) { return 320; /* Custom featured post image width */ }
add_filter( 'et_pb_blog_image_width', 'mycustom_featured_width');
function mycustom_featured_height( ) { return 260; /* Custom featured post image height */ }
add_filter( 'et_pb_blog_image_height', 'mycustom_featured_height');
function mycustom_featured_size( $image_sizes ) {
$custom_size = mycustom_featured_width() . 'x' . mycustom_featured_height();
@robertstaddon
robertstaddon / functions.php
Last active August 14, 2017 21:19
Divi - custom featured post image size (include default WordPress blog pages)
<?php
function mycustom_featured_width( ) { return 320; /* Custom featured post image width */ }
add_filter( 'et_pb_blog_image_width', 'mycustom_featured_width');
add_filter( 'et_pb_index_blog_image_width', 'mycustom_featured_width');
function mycustom_featured_height( ) { return 260; /* Custom featured post image height */ }
add_filter( 'et_pb_blog_image_height', 'mycustom_featured_height');
add_filter( 'et_pb_index_blog_image_height', 'mycustom_featured_height');
function mycustom_featured_size( $image_sizes ) {
@robertstaddon
robertstaddon / style.css
Created August 14, 2017 21:17
Divi - Style the custom featured image
@media all and (min-width: 768px) {
.et_pb_posts img {
float: left;
margin-right: 1em;
}
.et_pb_posts article:after { /* Clear floated image */
content: "";
display: table;
clear: both;
}