| @@ -2,13 +2,16 @@ | ||
| 2 | 2 | namespace MBSocial; |
| 3 | 3 | defined('ABSPATH') or die('No direct access permitted'); |
| 4 | 4 | |
| 5 | 5 | use MaxButtons\maxButton as maxButton; |
| 6 | +use MaxButtons\maxBlocks as maxBlocks; | |
| 6 | 7 | |
| 7 | 8 | $button = new maxButton(); // this loads the maxblocks template files |
| 8 | 9 | |
| 10 | + | |
| 11 | +$title = (Install::isPro()) ? __('Wordpress Share Buttons PRO', 'mbsocial') : __('WordPress Share Buttons','mbsocial'); | |
| 9 | 12 | $header = array( |
| 10 | - 'title' => __('WordPress Share Buttons','mbsocial') | |
| 13 | + 'title' => $title, | |
| 11 | 14 | ); |
| 12 | 15 | |
| 13 | 16 | $mainclass = 'maxbuttons-social-editor'; |
| 14 | 17 | $admin = mbSocial()->admin(); |
| @@ -15,40 +18,117 @@ | ||
| 15 | 18 | $admin->header($header); |
| 16 | 19 | |
| 17 | 20 | |
| 18 | 21 | $collection_ids = collections::getCollections(); |
| 22 | +$number_of_collections = count($collection_ids); | |
| 19 | 23 | |
| 24 | +$the_collection_id = isset($_GET['social_id']) ? intval($_GET['social_id']) : false; | |
| 20 | 25 | |
| 21 | -if (count($collection_ids) == 0) | |
| 22 | - $collection_ids = array(0); | |
| 26 | +if ($the_collection_id === false && $number_of_collections > 0 ) | |
| 27 | +{ | |
| 28 | + $the_collection_id = $collection_ids[0]; // load the first one | |
| 29 | +} | |
| 30 | +else { | |
| 31 | + $collection_id = 0; | |
| 32 | +} | |
| 33 | +?> | |
| 23 | 34 | |
| 35 | +<form class='mb-ajax-form save-on-key' data-action='save-share'> | |
| 24 | 36 | |
| 25 | -?> | |
| 26 | 37 | |
| 27 | -<?php foreach ($collection_ids as $collection_id): ?> | |
| 38 | +<?php if($number_of_collections > 0) : ?> | |
| 39 | +<div class='help-side collection_switcher'> | |
| 40 | + <h3><?php _e('Your Social Groups','mbsocial'); ?></h3> | |
| 41 | + <?php // | |
| 28 | 42 | |
| 29 | -<?php if ($collection_id > 0): ?> | |
| 30 | -<div class='mb-message shortcode'> | |
| 31 | - <?php printf(__('Shortcode for manual use: [maxsocial id="%s"]','mbsocial'), $collection_id); ?> | |
| 43 | + echo '<div class="item heading"><span>' . __('name', 'mbsocial') . '</span><span>' . __('no buttons', 'mbsocial') . '</span><span>' . __('shortcode', 'mbsocial') . '</span></div>'; | |
| 44 | + | |
| 45 | + foreach($collection_ids as $id) { | |
| 46 | + $collection = new collection($id); | |
| 47 | + $genBlock = $collection->getBlock('generalBlock'); | |
| 48 | + $name = $genBlock->getValue('name'); | |
| 49 | + $nwBlock = $collection->getBlock('networkBlock'); | |
| 50 | + | |
| 51 | + $networks_number = count($nwBlock->getValue('network_active')); // ) | |
| 52 | + | |
| 53 | + $name = ( strlen($name) > 0) ? $name : '#' . $id; | |
| 54 | + $active = ($id == $the_collection_id) ? 'active' : ''; | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + if ( Install::isPRO() ) | |
| 59 | + { | |
| 60 | + $link = '<a href="' . add_query_arg('social_id', $id) . '"><span>' . $name . '</span>'; | |
| 61 | + $linkend = '</a>'; | |
| 62 | + } | |
| 63 | + else { | |
| 64 | + $link = '<span>' . $name . '</span>'; | |
| 65 | + $linkend = ''; | |
| 66 | + } | |
| 67 | + echo '<div class="item ' . $active . '">'; | |
| 68 | + echo $link; | |
| 69 | + echo '<span> [' . $networks_number . ' buttons] </span>'; | |
| 70 | + echo '<span> [maxsocial id="' . $id . '"] </span>'; | |
| 71 | + echo $linkend; | |
| 72 | + echo '</div>'; | |
| 73 | + | |
| 74 | + } | |
| 75 | + | |
| 76 | + if ( Install::isPRO() ) | |
| 77 | + { | |
| 78 | + $link = '<a href="' . add_query_arg('social_id', 0) . '" title="' . __('Add', 'mbsocial') . '"> <span class="plus">+</span> ' . __('Add', 'mbsocial') . '</a>'; | |
| 79 | + } | |
| 80 | + else { | |
| 81 | + $link = '<a><span class="plus">+</span> ' . __('Add', 'mbsocial') . '</a>'; | |
| 82 | + } | |
| 83 | + | |
| 84 | + echo '<span class="item new">' . $link . '</span>'; | |
| 85 | + | |
| 86 | + | |
| 87 | + if (! Install::isPro() ) | |
| 88 | + { ?> | |
| 89 | + <div class='forpro overlay'><div><?php echo $admin->getProMessage(); ?></div></div> | |
| 90 | + <?php } ?> | |
| 32 | 91 | </div> |
| 33 | 92 | <?php endif; ?> |
| 34 | 93 | |
| 35 | -<form class='mb-ajax-form' data-action='save-share'> | |
| 94 | + <?php if ($the_collection_id > 0): | |
| 95 | + $collection_id = $the_collection_id; | |
| 96 | + ?> | |
| 97 | + | |
| 98 | + <div class='mb-message shortcode'> | |
| 99 | + <?php printf(__('Shortcode for manual use: [maxsocial id="%s"]','mbsocial'), $collection_id); ?> | |
| 100 | + </div> | |
| 101 | + <?php endif; ?> | |
| 102 | + | |
| 36 | 103 | <input type='hidden' name="collection_id" value="<?php echo $collection_id ?>" /> |
| 104 | + <input type='hidden' name="form_post" value="true" /> | |
| 37 | 105 | |
| 38 | - | |
| 39 | 106 | <div class="form-actions "> |
| 40 | - <button type="button" class="button-primary button-save mb-ajax-submit" data-action='save_collection'><?php _e('Save', 'maxbuttons') ?></button> | |
| 107 | + <button type="button" class="button-primary button-save mb-ajax-submit" data-action='save_collection'><?php _e('Save', 'mbsocial') ?></button> | |
| 108 | + <?php if ($collection_id > 0 && Install::isPro()): ?> | |
| 109 | + <button type='button' class='button remove maxmodal' data-modal='modal_remove'><?php _e('Delete', 'mbsocial'); ?></button> | |
| 110 | + <?php endif; ?> | |
| 41 | 111 | </div> |
| 42 | 112 | |
| 113 | + | |
| 43 | 114 | <?php include('share_editor.php'); ?> |
| 44 | 115 | |
| 45 | - <?php //$admin->output_defined_fields(); ?> | |
| 46 | 116 | |
| 117 | + <div class="form-actions"> | |
| 118 | + <button type="button" class="button-primary button-save mb-ajax-submit" data-action='save_collection'><?php _e('Save', 'mbsocial') ?></button> | |
| 119 | + </div> | |
| 47 | 120 | |
| 121 | + <div id='modal_remove' class='maxmodal-data'> | |
| 122 | + <div class='title'><?php _e('Delete Social Group', 'mbsocial'); ?></div> | |
| 123 | + <span class="content"><p><?php _e("You are about to permanently remove this Social Group. Are you sure?", "mbsocial"); ?></p></span> | |
| 124 | + <div class='controls'> | |
| 125 | + <button type="button" class='button-primary mb-ajax-action' data-action='remove-collection' data-param='<?php echo $collection_id ?>'> | |
| 126 | + <?php _e('Yes','mbsocial'); ?></button> | |
| 48 | 127 | |
| 49 | - <div class="form-actions"> | |
| 50 | - <button type="button" class="button-primary button-save mb-ajax-submit" data-action='save_collection'><?php _e('Save', 'maxbuttons') ?></button> | |
| 51 | - </div> | |
| 128 | + <a class="modal_close button-primary"><?php _e("No", "mbsocial"); ?></a> | |
| 129 | + | |
| 130 | + </div> | |
| 131 | + | |
| 132 | + </div> <!-- modal --> | |
| 52 | 133 | <?php $admin->footer(); ?> |
| 53 | 134 | </form> |
| 54 | -<?php endforeach; ?> | |