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