Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 57aecf1
Showing
14 changed files
with
324 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
.thumbs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
################################################################################################## | ||
_____ _ _ _ _ | ||
/ ____| | | | | (_) | | ||
| | ___ _ __ _ __ ___ _ __ ___| |_ ___ _ __ ___ | | _| |__ _ __ __ _ _ __ _ _ | ||
| | / _ \| '__| '_ \ / _ \ '__/ __| __/ _ \| '_ \ / _ \ | | | | '_ \| '__/ _` | '__| | | | | ||
| |___| (_) | | | | | | __/ | \__ \ || (_) | | | | __/ | |____| | |_) | | | (_| | | | |_| | | ||
\_____\___/|_| |_| |_|\___|_| |___/\__\___/|_| |_|\___| |______|_|_.__/|_| \__,_|_| \__, | | ||
|__ __| | | | | __/ | | ||
| | ___ _ __ ___ _ __ | | __ _| |_ ___ |___/ | ||
| |/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \ | ||
| | __/ | | | | | |_) | | (_| | || __/ | ||
|_|\___|_| |_| |_| .__/|_|\__,_|\__\___| | ||
| | | ||
|_| | ||
|
||
################################################################################################# | ||
|
||
This plugin template has all the basics you need to get started with building your own custom element for the Cornerstone Page Builder for WordPress. It was created by William <hello@bigwilliam.com>. Please let me know what you thing of this template, or ask me anything, at http://cornerstonelibrary.com/contact | ||
|
||
Cornerstone Library is a collection of community developed elements for Cornerstone. Learn more at: http://cornerstonelibrary.com | ||
|
||
For more information about building Cornerstone Elements, please reference: | ||
https://theme.co/community/kb/cornerstone-custom-elements/ | ||
|
||
_____________________________________________________________ | ||
|
||
## Here's a couple things to keep in mind about this template: | ||
|
||
1. This plugin depends on the Cornerstone Page Builder plugin to be installed first. Learn more here: http://theme.co/cornerstone/ | ||
|
||
2. It is strongly suggested that you keep the Plugin name in the following format: | ||
"Cornerstone Library: {{your custom name here}}" | ||
|
||
3. You'll need to replace each instance of "Template Name" with your own custom name: (recommend search-replace across all files, case sensitive) | ||
- Template_Name | ||
- template_name | ||
- template-name | ||
- Template Name | ||
|
||
4. Here's some useful tips for building your own element: | ||
- Browse the elements already made in Cornerstone to see what types of fields you can use: yoursite.com/wp-content/plugins/cornerstone/includes/modules/elements | ||
- Check out the Themeco documentation (in case you missed it above): https://theme.co/community/kb/cornerstone-custom-elements/ | ||
|
||
5. When you are finished creating your custom element, submit it at http://cornerstonelibrary.com/submit !!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* CSS for your custom element goes here */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
// silence is golden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
// silence is golden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
// silence is golden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
jQuery(document).ready(function($) { | ||
// your custom jQuery here | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
// silence is golden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/* | ||
Plugin Name: Cornerstone Library: Template Name | ||
Plugin URI: http://cornerstonelibrary.com/ | ||
Description: This is a template plugin for creating new elements for Cornerstone | ||
Version: 0.1 | ||
Author: Your Name | ||
Author URI: http://yourwebsite.com | ||
Author Email: youremail@example.com | ||
Text Domain: __x__ | ||
*/ | ||
|
||
|
||
// If this file is called directly, abort. | ||
if ( ! defined( 'WPINC' ) ) { | ||
die; | ||
} | ||
|
||
/* | ||
* => Enqueue Scripts | ||
* ---------------------------------------------------------------------------*/ | ||
function csl_template_name_scripts() { | ||
wp_enqueue_script( 'csl-template-name-script', plugins_url( '/assets/js/custom.js', __FILE__ ), array( 'jquery' ), null, true ); | ||
wp_enqueue_style( 'csl-template-name-css', plugins_url( '/assets/css/custom.css', __FILE__ ), array(), '1.0' ); | ||
} | ||
add_action( 'wp_enqueue_scripts', 'csl_template_name_scripts', 100 ); | ||
|
||
|
||
/* | ||
* => Load Shortcodes | ||
* ---------------------------------------------------------------------------*/ | ||
require_once('includes/shortcodes.php'); | ||
|
||
/* | ||
* => ADD CUSTOM ELEMENTS TO CORNERSTONE | ||
* ---------------------------------------------------------------------------*/ | ||
function csl_template_name_elements() { | ||
require_once( 'includes/template-name-element.php' ); | ||
require_once( 'includes/template-name-element-item.php' ); // include this if your item has a child type | ||
cornerstone_add_element( 'CSL_Template_Name' ); | ||
cornerstone_add_element( 'CSL_Template_Name_Item' ); | ||
} | ||
add_action( 'cornerstone_load_elements', 'csl_template_name_elements' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
// silence is golden |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
|
||
// Adv Accordion | ||
// ============================================================================= | ||
|
||
function csl_shortcode_template_name( $atts, $content = null ) { | ||
extract( shortcode_atts( array( | ||
'id' => '', | ||
'class' => '', | ||
'style' => '' | ||
), $atts, 'csl_template_name' ) ); | ||
|
||
$id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; | ||
$class = ( $class != '' ) ? 'class="csl-template-name ' . esc_attr( $class ) . '"' : 'csl-template-name'; | ||
$style = ( $style != '' ) ? 'style="' . $style . '"' : ''; | ||
|
||
$output = "<div {$id} {$class} {$style}>" . do_shortcode( $content ) . "</div>"; | ||
|
||
return $output; | ||
} | ||
|
||
add_shortcode( 'csl_template_name', 'csl_shortcode_template_name' ); | ||
|
||
|
||
|
||
// Adv Accordion Item | ||
// ============================================================================= | ||
|
||
function csl_shortcode_template_name_item( $atts, $content = null ) { | ||
extract( shortcode_atts( array( | ||
'id' => '', | ||
'class' => '', | ||
'style' => '', | ||
'parent_id' => '', | ||
'title' => '', | ||
), $atts, 'csl_template_name_item' ) ); | ||
|
||
$id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; | ||
$class = ( $class != '' ) ? 'class="csl-template-name-item ' . esc_attr( $class ) : 'csl-template-name-item'; | ||
$style = ( $style != '' ) ? 'style="' . $style . '"' : ''; | ||
$parent_id = ( $parent_id != '' ) ? 'data-parent="#' . $parent_id . '"' : ''; | ||
$title = ( $title != '' ) ? $title : 'Make Sure to Set a Title'; | ||
$open = ( $open == 'true' ) ? 'collapse in' : 'collapse'; | ||
|
||
static $count = 0; $count++; | ||
|
||
if ( $open == 'collapse in' ) { | ||
|
||
$output = "<div {$id} {$class} {$style}>" | ||
. '<div class="x-accordion-heading">' | ||
. "<a class=\"x-accordion-toggle\" {$color} data-toggle=\"collapse\" {$parent_id} href=\"#collapse-{$count}\"><span class=\"adv-title\">{$title}</span> <span class=\"extra-title\">{$title_extra}</span></a>" | ||
. '</div>' | ||
. "<div id=\"collapse-{$count}\" class=\"accordion-body {$open}\">" | ||
. '<div class="x-accordion-inner">' | ||
. do_shortcode( $content ) | ||
. '</div>' | ||
. '</div>' | ||
. '</div>'; | ||
|
||
} else { | ||
|
||
$output = "<div {$id} class=\"{$class}\" {$style}>" | ||
. '<div class="x-accordion-heading">' | ||
. "<a class=\"x-accordion-toggle collapsed\" {$color} data-toggle=\"collapse\" {$parent_id} href=\"#collapse-{$count}\"><span class=\"adv-title\">{$title}</span> <span class=\"extra-title\">{$title_extra}</span></a>" | ||
. '</div>' | ||
. "<div id=\"collapse-{$count}\" class=\"accordion-body {$open}\">" | ||
. '<div class="x-accordion-inner">' | ||
. do_shortcode( $content ) | ||
. '</div>' | ||
. '</div>' | ||
. '</div>'; | ||
|
||
} | ||
|
||
return $output; | ||
} | ||
|
||
add_shortcode( 'csl_template_name_item', 'csl_shortcode_template_name_item' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
/** | ||
* | ||
* To discover more fields you can use, see examples from current Cornerstone elements! Here's where you'll find them: | ||
* In the Cornerstone plugin, look in /includes/modules/elements/ and /includes/modules/shortcodes | ||
* | ||
* You can find the function reference and inline documentation in this file (of the Cornerstone Plugin): | ||
* ------------------------------------------- | ||
* | /cornerstone/includes/utility/api.php | | ||
* ------------------------------------------- | ||
* | ||
* For more documentation, please see: https://theme.co/community/kb/cornerstone-custom-elements/ | ||
* | ||
**/ | ||
?> | ||
|
||
<?php | ||
|
||
class CSL_Template_Name_Item extends Cornerstone_Element_Base { | ||
|
||
public function data() { | ||
return array( | ||
'name' => 'csl-template-name-item', | ||
'title' => __( 'Template Name Item', csl18n() ), | ||
'section' => '_content', | ||
'description' => __( 'Template Name Item description.', csl18n() ), | ||
'supports' => array( 'id', 'class', 'style' ), | ||
'render' => false, | ||
'delegate' => true | ||
); | ||
} | ||
|
||
public function controls() { | ||
|
||
$this->addControl( | ||
'title', // control name | ||
'title', // control type | ||
NULL, // message | ||
NULL, // tooltip text | ||
'' // placeholder text | ||
); | ||
|
||
$this->addControl( | ||
'content', // control name | ||
'editor', // control type | ||
__( 'Content', csl18n() ), // message | ||
__( 'Include your desired content for your Template Name Item here.', csl18n() ), // tooltip text | ||
'' // placehlder text | ||
); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?php | ||
/** | ||
* | ||
* To discover more fields you can use, see examples from current Cornerstone elements! Here's where you'll find them: | ||
* In the Cornerstone plugin, look in /includes/modules/elements/ and /includes/modules/shortcodes | ||
* | ||
* You can find the function reference and inline documentation in this file (of the Cornerstone Plugin): | ||
* ------------------------------------------- | ||
* | /cornerstone/includes/utility/api.php | | ||
* ------------------------------------------- | ||
* | ||
* For more documentation, please see: https://theme.co/community/kb/cornerstone-custom-elements/ | ||
* | ||
**/ | ||
?> | ||
|
||
<?php | ||
|
||
class CSL_Template_Name extends Cornerstone_Element_Base { | ||
|
||
public function data() { | ||
return array( | ||
'name' => 'csl-template-name', | ||
'title' => __( 'Template Name', csl18n() ), | ||
'section' => 'content', | ||
'description' => __( 'Template Name description.', csl18n() ), | ||
'supports' => array( 'id', 'class', 'style' ), | ||
'childType' => 'csl-template-name-item', | ||
'renderChild' => true | ||
); | ||
} | ||
|
||
public function controls() { | ||
|
||
$this->addControl( | ||
'elements', // control name | ||
'sortable', // control type | ||
__( 'Template Name Items', csl18n() ), // Message | ||
__( 'Add a new item to your Template Name.', csl18n() ), // Tooltip text | ||
array( | ||
array( 'title' => __( 'Template Name 1', csl18n() ), 'content' => __( 'Add some content to your Template Name here.', csl18n() ) ), | ||
array( 'title' => __( 'Template Name 2', csl18n() ), 'content' => __( 'Add some content to your Template Name here.', csl18n() ) ) | ||
), // placeholder content or default items | ||
array( | ||
'newTitle' => __( 'Template Name %s', csl18n() ), | ||
'floor' => 1 | ||
) // new item format | ||
); | ||
|
||
$this->addSupport( 'id', | ||
array( 'options' => array( 'monospace' => true ) ) | ||
); | ||
} | ||
|
||
public function render( $atts ) { | ||
|
||
extract( $atts ); | ||
|
||
$contents = ''; | ||
|
||
foreach ( $elements as $e ) { | ||
|
||
$item_extra = $this->extra( array( | ||
'id' => $e['id'], | ||
'class' => $e['class'], | ||
'style' => $e['style'] | ||
) ); | ||
|
||
$e['parent_id'] = ( $link_items == 'true' && $id != '' ) ? $id : ''; | ||
|
||
$contents .= '[csl_template_name_item title="' . $e['title'] . '" '; | ||
$contents .= 'open="' . $e['open'] . '"' . $item_extra . ']' . $e['content'] . '[/csl_template_name_item]'; | ||
|
||
} | ||
|
||
$shortcode = "[csl_template_name{$extra}]{$contents}[/csl_template_name]"; | ||
|
||
return $shortcode; | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
// silence is golden |