public function get_post_id_by_slug($postName)
{
- $value = $this->wpdb->get_var("SELECT ID FROM ".$this->wpdb->posts." WHERE post_name = '".$postName."'");
+ $value = $this->wpdb->get_var("SELECT ID FROM ". $this->wpdb->posts." WHERE post_name = '" . $postName."'");
return $value;
}
public function shortcode_builder_markup_template($shortCodes, $list) {
//dropdown for shortcode names
$this->increase_shortcode_count();
- echo '<div id="categoryContainer" class="'.$this->get_shortcode_count().'" style="overflow: auto">';
+ echo '<div id="shortcode_container" class="'.$this->get_shortcode_count().'" style="overflow: auto">';
echo '<div id="shortcodeBuilder">';
- echo '<select id="shortcodeDropdown">
+ echo '<select id="shortcodeDropdown" class="shortcodeDropdown">
<option value=""> Select Shortcode </option>';
foreach($shortCodes as $code){
if (false !== strpos($code, 'members-list') || false !== strpos($code, 'packaging-list')){
}
}
echo '</select>';
-
- echo '<div id="categoryBox" title="Member Categories ">';
- foreach($list as $key=>$value){
- if( ! empty($value['parent']['name'])){
- echo '<label class="checkList" for="'.$value['name'].'"><input class="categoryLists" type="checkbox" name="listBox" value='. $key . '>' . '   '. $value['name'] .'</label>';
- } else {
- echo '<label class="checkList" for="'.$value['name'].'"><input class="categoryLists" type="checkbox" name="listBox" value='. $key . '>' . ' '. $value['name'] .'</label>';
- }
- }
- echo '</div>';
// dropdown for blank start
echo '<select id="blank-start-scDropdown">';
echo '<option value="grid"> Grid View </option>';
echo '</select>';
- // show list options 'scb' = shortcode builder acronym
-// echo '<div id="showList" title="List Options">';
-// echo '<label><input class="showLists" type="checkbox" name="listBox" value="all">All</label>';
-// echo '<label><input class="showLists" type="checkbox" name="listBox" value="none">None</label>';
-// foreach($listAttr as $key=>$value){
-// if($value != ''){
-// echo '<label class="checkList"><input class="showLists" type="checkbox" name="listBox" value='. $key . '>' . $key .'</label>';
-// }
-// }
-// echo '</div>';
-
- // show detail options
-// echo '<div id="showDetail" title="Detail Options">';
-// echo '<label><input class="showDetails" type="checkbox" name="detailBox" value="all">All</label>';
-// echo '<label><input class="showDetails" type="checkbox" name="detailBox" value="none">None</label>';
-// foreach($detailAttr as $key=>$value){
-// if($value != ''){
-// echo '<label class="checkDetails"><input class="showDetails" type="checkbox" name="detailBox" value='. $key . '>' . $key .'</label>';
-// }
-// }
-
// packaging addOn mark up
if(file_exists(GLM_MEMBERS_PACKAGING_PLUGIN_PATH . "/setup/shortcodeBuilder.php")){
include GLM_MEMBERS_PACKAGING_PLUGIN_PATH . "/setup/shortcodeBuilder.php";
// This function when called will auto-increment the shortcode ID
$this->shortcode_builder_markup_template($shortCodes, $list);
-
+ ?>
+ <script type="text/javascript">
+ jQuery(document).ready( function () {
+ jQuery("#additionalShortcode").click( function () {
+
+ });
+ });
+ </script>
+
+
+ <?php
// It should be able to be called several times (once every time the
// additionalShortcode button is clicked), but there are still some
// issues with that. Nice-print conflict..
- $this->shortcode_builder_markup_template($shortCodes, $list);
+// $this->shortcode_builder_markup_template($shortCodes, $list);
// This button will add another shortcode editor
+
echo '<button id="additionalShortcode" class="button" type="button"> Configure Additional Shortcode </button>';
}
}
jQuery(document).ready(function ($) {
'use strict';
-
+
var shortcodeDropdown, shortcodeCategory, blankStart, listBox, detailBox, target, boxTarget, shortcodeString,
editor_shortcodes, category_id, shortcodeValues = {};
+
$("#showDetail").hide();
$("#categoryBox").hide();
$("#showCategory").hide();
$(".scCategories").hide();
// reset checkboxes after page load
- function uncheckAll() {
- var w = document.getElementsByTagName('input');
- for (var i = 0; i < w.length; i++){
- if(w[i].type === 'checkbox'){
- w[i].checked = false;
- }
- }
- }
-
-
+// function uncheckAll() {
+// var w = document.getElementsByTagName('input');
+// for (var i = 0; i < w.length; i++){
+// if(w[i].type === 'checkbox'){
+// w[i].checked = false;
+// }
+// }
+// }
+ var shortcode = $("#shortcode_container").not('.glm-dynSelect-item'), clone, id_count;
+ id_count = 0;
+// $("#additionalShortcode").on( "click", function () {
+// id_count++;
+// clone = shortcode.clone(true);
+// clone.find("#shortcodeDropdown").attr("id", "shortcodeDropdown" + "_" + id_count);
+// clone.find(".glm-dynSelect-item").remove();
+// clone.find("#generate").attr("id", "generate" + "_" + id_count);
+// clone.insertAfter("#shortcode_container:last");
+//
+// });
+
/////////////////////////////////////////////////////////////////////////////////////////
// CHANGE MAIN SHORTCODE
/////////////////////////////////////////////////////////////////////////////////////////
// fire core events and reset settings when switching between shortcodes
- $("#shortcodeDropdown").on("change", function () {
+ $("[id$=shortcodeDropdown]").on("change", function () {
// reset the dropdowns and checkbox if when switching shortcodes
document.getElementById('category-scDropdown').options[0].selected = 'selected';
if($('#blank-start-scDropdown').length)
if($('#id-scDropdown').length)
document.getElementById('id-scDropdown').options[0].selected = 'selected';
- uncheckAll();
+// uncheckAll();
// delete the object properties to reset the object
shortcodeString = "";
}
// get the shortcode option name and hide / show necessary elements
- shortcodeDropdown = $("#shortcodeDropdown option:selected").val();
+ shortcodeDropdown = $(".shortcodeDropdown option:selected").val();
if(shortcodeDropdown === "glm-members-list"){
$("#showCategory").show();
}
editor_shortcodes = get_tinymce_content();
+
if(editor_shortcodes){
var number_of_categories = (editor_shortcodes.match(/category="(.*?)"/g) || []).length;
}
console.debug(number_of_categories);
+ console.debug(editor_shortcodes);
if(editor_shortcodes){
if(editor_shortcodes.match(/category="(.*?)"/) !== null){
category_id = editor_shortcodes.match(/category="(.*?)"/)[1];
+// console.debug(category_id);
+// var cat_id_array = [];
+// $.each(category_id, function (key, value) {
+// cat_id_array.push(value.match(/"(.*?)"/)[1]);
+// });
+
category_id = category_id.split(',');
+
} else if (editor_shortcodes.match(/category=""/) !== null){
category_id = editor_shortcodes.match(/category="(.*?)"/)[1];
}
// INSERT SHORTCODE FUNCTION
/////////////////////////////////////////////////////////////////////////////////////////////////
// generate the shortcode into a string and insert into the content upon clicking
- $("#generate").on("click", function () {
+ $("[id$=generate]").on("click", function () {
count = 0;
if(number_of_categories){
count = number_of_categories;
}
}
// start the shortcode string that will be added to the tinymce editor
- shortcodeString = '<div class="previewCodes" id="' + shortcodeDropdown + '_'+ count + '"> [' + shortcodeDropdown;
+ shortcodeString = '<div class="previewCodes" id="' + count + '"> [' + shortcodeDropdown;
// populate the shortcode object
for (var key in shortcodeValues) {
editor_shortcodes = get_tinymce_content();
- if(editor_shortcodes.match(/category="(.*?)"/) !== null){
+ if(editor_shortcodes && editor_shortcodes.match(/category="(.*?)"/) !== null){
category_id = editor_shortcodes.match(/category="(.*?)"/)[1];
category_id = category_id.split(',');
ids = category_id.join(',');
if(view){
window.onload = document.getElementById('view-scDropdown').options[0].selected = 'selected';
}
- window.onload = uncheckAll();
+// window.onload = uncheckAll();
});