Skip to content

Instantly share code, notes, and snippets.

@Bicarbona
Last active June 27, 2016 15:50
Show Gist options
  • Save Bicarbona/70581cefc79b36e7a57d393673b652ed to your computer and use it in GitHub Desktop.
Save Bicarbona/70581cefc79b36e7a57d393673b652ed to your computer and use it in GitHub Desktop.
Customize the DMS
<?php
// From http://www.pagelinestheme.com/disable-dms-regions-per-page/
//Disable Fixed, Header, and Footer on all these Page IDs
add_filter( 'pl_setting-region_disable_fixed', 'customize_templates_by_page' );
add_filter( 'pl_setting-region_disable_header', 'customize_templates_by_page' );
add_filter( 'pl_setting-region_disable_footer', 'customize_templates_by_page' );
function customize_templates_by_page() {
//could choose to still show for Admins (e.g. copy content from footer to template)
//if( current_user_can('edit_theme_options') ) { return false; }
global $post;
$pageids = array(
182, //http://example.com/snowy/
<?php
/*
Plugin Name: PageLines DMS Toolbar Customizer
Author: TourKick (Clifford P)
Author URI: http://tourkick.com/?utm_source=pagelines&utm_medium=plugin&utm_content=pluginuri&utm_campaign=dmstoolbarcustomizer
Plugin URI: http://www.pagelinestheme.com/remove-dms-editor-toolbar-items-2/?utm_source=pagelines&utm_medium=plugin&utm_content=pluginuri&utm_campaign=dmstoolbarcustomizer
Description: Removes 'Get More Sections' link from Add To Page panel, removes Theme panel, and removes DMS panel from the DMS editor for non-Administrators (e.g. Editors). <strong>Edit the plugin's file to customize other options.</strong> May also choose to copy code directly into your DMS child theme's functions.php file instead of activating this plugin. <a href="http://www.pagelinestheme.com/dms-editor-lock-down/" target="_blank">http://www.pagelinestheme.com/dms-editor-lock-down/</a> may also be helpful.
License: GPLv2
Version: 1.1.20131105
*/
add_filter('pl_toolbar_config','pagelines_dms_toolbar_customizer',11, 2);
function pagelines_dms_toolbar_customizer( $toolbar ){
if(
!current_user_can('manage_options') // the uncommented items below only get removed for non-Administrators who also have access to the PageLines DMS Editor
//&& get_current_user_id() !== '1' // could also choose to limit to certain Administrators via user ID
){
//unset($toolbar['add-new']); //Add To Page (Sections)
unset( $toolbar['add-new']['panel']['more_sections']); // Add To Page -- Get More Sections
//unset($toolbar['page-setup']); //Templates
//unset($toolbar['settings']); //Settings (Global Options)
//unset( $toolbar['settings']['panel']['importexport']); // Settings -- Import + Export
//unset( $toolbar['settings']['panel']['advanced']); // Settings -- Advanced
unset($toolbar['theme']); //Theme
//unset( $toolbar['theme']['panel']['avail_themes']); // Theme -- Your Themes
//unset( $toolbar['theme']['panel']['more_themes']); // Theme -- Get More Themes
// do not use, makes DMS not load -- unset($toolbar['pl-design']); //Custom Code
//unset( $toolbar['pl-design']['panel']['user_less']); // Custom -- Custom LESS/CSS
//unset( $toolbar['pl-design']['panel']['user_scripts']); // Custom -- Custom Scripts
unset($toolbar['account']); //DMS
//unset( $toolbar['account']['panel']['pl_account']); // DMS -- Your Account (like defining DMS_DISABLE_ACCOUNT_PANEL constant in wp-config.php)
//unset( $toolbar['account']['panel']['getting_started']); // DMS -- Getting Started
//unset( $toolbar['account']['panel']['support']); // DMS -- Getting Started
//unset($toolbar['toggle-grid']); //Preview
}
return $toolbar;
}
219, //http://example.com/rainy/
);
if(is_page($pageids)) {
return true; // true is checkbox ticked
}
}
//from http://www.pagelinestheme.com/remove-customize-dms-editors-media-uploads-prefix/
//replace 'PageLines-' prefix for DMS Editor media uploads (from editor/editor.actions.php)
add_filter( 'pl_up_image_prefix', 'my_pl_upload_prefix');
function my_pl_upload_prefix(){
return ''; //example result: 'filename.png'
//return 'My Keyword - '; //example result: 'My Keyword - filename.jpg'
//return get_bloginfo('name','raw') . ' - '; //example result: 'Site Name - filename.gif'
}
<?php
//from http://www.pagelinestheme.com/removing-dms-2-karma-counter/
//remove display of Karma Counter in DMS 2
remove_shortcode( 'pl_karma' );
add_shortcode( 'pl_karma', '__return_false' );
<?php
// from http://www.pagelinestheme.com/stop-cropping-featured-images/
// related to http://www.pagelinestheme.com/access-remove-pagelines-custom-image-sizes/
function pl_dms_override_thumbs(){
//add_image_size( 'aspect-thumb', 900, 600, false );
add_image_size( 'basic-thumb', 400, 400, false );
add_image_size( 'landscape-thumb', 900, 450, false );
}
add_action('after_setup_theme', 'pl_dms_override_thumbs', 11);
<?php
//check-for-pagelines-dms
if( function_exists('pl_has_editor') ){
//PageLines v3 (DMS) is the current theme
}
if( !function_exists('pl_has_editor') ){
//PageLines v3 (DMS) is NOT the current theme
}
<?php
// check-for-pagelines-framework
if( function_exists('ploption') && !function_exists('pl_has_editor') ){
//PageLines v2 (Framework) is the current theme
}
//check-for-pagelines-parent-theme-string
<?php
// used in Action Map plugin ( https://github.com/pagelines/pagelines-action-map )
$dir = basename( get_template_directory() );
if ( 'pagelines' != $dir && 'dms' != $dir ){
//neither PageLines v2 (Framework) nor v3 (DMS) is the current theme
}
// check-for-pagelines-ploption
<?php
if( function_exists('ploption') ){
//PageLines v2 (Framework) or v3 (DMS) is the current theme
}
if( !function_exists('ploption') ){
//neither PageLines v2 (Framework) nor v3 (DMS) is the current theme
}
<?php
// globally displays page titles in PageLines DMS
add_action( 'loop_start', 'pldmspagetitles');
function pldmspagetitles() {
if( is_page() /* && !is_front_page() && !is_page(54) */ ) {
printf( '<h1>%s</h1>', get_the_title() );
}
}
<?php
/*
Plugin Name: PageLines DMS Tell Me Type and Template
Author: TourKick (Clifford P)
Author URI: http://tourkick.com/?utm_source=pagelines&utm_medium=plugin&utm_content=pluginuri&utm_campaign=dmstellmetemplate
Plugin URI: http://www.pagelinestheme.com/tell-me-dms-type-template/?utm_source=pagelines&utm_medium=plugin&utm_content=pluginuri&utm_campaign=dmstellmetemplate
Description: Shows logged in editors which PageLines DMS "page type" and "applied template" is detected by the DMS Editor. May also choose to copy code directly into your DMS child theme's functions.php file instead of activating this plugin. <a href="http://www.pagelinestheme.com/tell-me-dms-type-template/" target="_blank">http://www.pagelinestheme.com/tell-me-dms-type-template/</a> may also be helpful.
License: GPLv2
Version: 1.0.20131002
*/
add_action('pagelines_page', 'tellmepldmstypetemplate'); // many other hooks, like wp_header, conflict with PL Action Map
function tellmepldmstypetemplate(){
if( function_exists('pl_has_editor') && current_user_can('edit_theme_options') ){
global $plpg;
echo '<span class="tellmepldmstypetemplate alert-info">PageLines Page Type: <strong>' . $plpg->type_name . '</strong>. Applied Template: <strong>' . $plpg->template . '</strong>.</span>';
}
}
//Remove display of Karma Counter in DMS 2
<?php
//from http://www.pagelinestheme.com/removing-dms-2-karma-counter/
//remove display of Karma Counter in DMS 2
remove_shortcode( 'pl_karma' );
add_shortcode( 'pl_karma', '__return_false' );
// Replace 'PageLines-' prefix for DMS Editor media uploads (from editor/editor.actions.php)
<?php
//from http://www.pagelinestheme.com/remove-customize-dms-editors-media-uploads-prefix/
//replace 'PageLines-' prefix for DMS Editor media uploads (from editor/editor.actions.php)
add_filter( 'pl_up_image_prefix', 'my_pl_upload_prefix');
function my_pl_upload_prefix(){
return ''; //example result: 'filename.png'
//return 'My Keyword - '; //example result: 'My Keyword - filename.jpg'
//return get_bloginfo('name','raw') . ' - '; //example result: 'Site Name - filename.gif'
}
// Change content-width sections inside a DMS Canvas Area to full-width
// from http://www.pagelinestheme.com/make-content-width-section-full-width/
// overriding dms/dms/less/pl-structure.less
body.display-boxed #site .boxed-wrap .pl-area.makestuffinsidefullwidth .pl-area-wrap > .pl-content {
padding-left: 0px;
padding-right: 0px;
}
body.display-full #site .pl-area.makestuffinsidefullwidth .pl-content {
max-width: none;
}
// optional to remove section padding from the sections you put inside
body #site .pl-area.makestuffinsidefullwidth .pl-section .pl-section > .pl-section-pad {
padding: 0px;
}
<?php
// From http://www.pagelinestheme.com/disable-dms-regions-per-page/
//Disable Fixed, Header, and Footer on all these Page IDs
add_filter( 'pl_setting-region_disable_fixed', 'customize_templates_by_page' );
add_filter( 'pl_setting-region_disable_header', 'customize_templates_by_page' );
add_filter( 'pl_setting-region_disable_footer', 'customize_templates_by_page' );
function customize_templates_by_page() {
//could choose to still show for Admins (e.g. copy content from footer to template)
//if( current_user_can('edit_theme_options') ) { return false; }
global $post;
$pageids = array(
182, //http://example.com/snowy/
219, //http://example.com/rainy/
);
if(is_page($pageids)) {
return true; // true is checkbox ticked
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment