Skip to content
This repository was archived by the owner on May 31, 2021. It is now read-only.

Template shortcode field size, name attribute #145

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Feel free to add to the todo lists

* Caps - allow users with post edit capabilities to build templates
- authors should only able to edit own template
* Template duplications
* Localization

## FUTURE / REQUESTS
Expand All @@ -21,3 +20,4 @@ Feel free to add to the todo lists
* Move template manager on a separate section, preferably similar to how it's done on Menus
* UI minor revamps to follow current WP UI
* Visual Editor
* Template duplications/clone
2 changes: 1 addition & 1 deletion assets/stylesheets/aqpb.css
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ a:hover, a:active, a:focus { color: #d54e21; }
float: left;
}
#template-shortcode input {
width: 120px;
width: auto;
height: 2em;
}

Expand Down
11 changes: 6 additions & 5 deletions classes/class-aq-page-builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ function create_template($title) {
*
* @since
*/
function clone_template( $template_id ){
function clone_template( $template_id, $count = 1 ){

//verify template
if( !$template_id ) return;
Expand All @@ -374,7 +374,7 @@ function clone_template( $template_id ){
$post = get_post( $template_id );

//set up template name
$template_name = $post->post_title.'_copy';
$template_name = "{$post->post_title} Copy {$count}";

//create new template only if title don't yet exist
if( !get_page_by_title( $template_name, 'OBJECT', 'template' ) ) {
Expand Down Expand Up @@ -403,7 +403,7 @@ function clone_template( $template_id ){
}

} else {
return new WP_Error('duplicate_template', 'Template names must be unique, try a different name');
return $this->clone_template( $template_id, $count+1 );
}

//return the new template ID
Expand Down Expand Up @@ -705,15 +705,16 @@ function add_media_display() {
<script type="text/javascript">
function insertTemplate() {
var id = jQuery( '#select-aqpb-template' ).val();

var name = jQuery( '#select-aqpb-template' ).find("option:selected").text();

/** Alert user if there is no template selected */
if ( '' == id ) {
alert("<?php echo esc_js( __( 'Please select your template first!', 'aqpb' ) ); ?>");
return;
}

/** Send shortcode to editor */
window.send_to_editor('[template id="' + id + '"]');
window.send_to_editor('[template id="' + id + '" name="' + name + '"]');
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion contribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ Here are some guidelines:
Please feel free to add yourself on this list :)

* [Syamil MJ](http://aquagraphite.com) (author)
* [Saroj] (Contributor)
* [Saroj](https://github.com/sarojlakra)