| @@ -1,54 +1,56 @@ | ||
| 1 | -<?php | |
| 2 | -namespace MBSocial; | |
| 1 | +<?php | |
| 2 | +namespace MBSocial; | |
| 3 | 3 | defined('ABSPATH') or die('No direct access permitted'); |
| 4 | 4 | |
| 5 | -// defined $post_type and $post in function | |
| 5 | +// defined $post_type and $post in function | |
| 6 | 6 | use MaxButtons\maxButton as maxButton; |
| 7 | -$button = MB()->getClass('button'); // this loads the maxblocks template files | |
| 7 | +$button = new maxButton(); // this loads the maxblocks template files | |
| 8 | 8 | |
| 9 | 9 | $collection_ids = collections::getCollections(); |
| 10 | 10 | |
| 11 | 11 | if (count($collection_ids) == 0) |
| 12 | 12 | return; // no collection no meta |
| 13 | - | |
| 13 | + | |
| 14 | 14 | foreach ($collection_ids as $collection_id) |
| 15 | 15 | { |
| 16 | - $collection = new collection($collection_id); | |
| 16 | + $collection = new collection($collection_id); | |
| 17 | + | |
| 18 | + $content_blocks = $collection->do_meta_boxes($post_type, $post); // see if we have anything to metabox. | |
| 19 | + | |
| 20 | + | |
| 21 | + if (! is_array($content_blocks) || count($content_blocks) == 0) | |
| 22 | + return; | |
| 17 | 23 | |
| 18 | - $content_blocks = $collection->do_meta_boxes($post_type, $post); // see if we have anything to metabox. | |
| 19 | - | |
| 20 | - | |
| 21 | - if (! is_array($content_blocks) || count($content_blocks) == 0) | |
| 22 | - return; | |
| 23 | - | |
| 24 | 24 | add_meta_box('mbsocial-box', |
| 25 | 25 | __( 'MaxButtons Social Share', 'mbsocial' ), |
| 26 | - MBSocial()->admin()->namespaceit('render_meta_box'), | |
| 26 | + MBSocial()->admin()->namespaceit('render_meta_box'), | |
| 27 | 27 | null, |
| 28 | 28 | 'advanced', |
| 29 | - 'default', | |
| 29 | + 'default', | |
| 30 | 30 | array('content_blocks' => $content_blocks) |
| 31 | 31 | ); |
| 32 | -} | |
| 32 | +} | |
| 33 | 33 | |
| 34 | -function render_meta_box($post, $args) | |
| 34 | +function render_meta_box($post, $args) | |
| 35 | 35 | { |
| 36 | - $content_blocks = isset($args['args']['content_blocks']) ? $args['args']['content_blocks'] : array(); | |
| 37 | - | |
| 38 | - if ( ! is_array($content_blocks) || count($content_blocks) == 0) | |
| 39 | - return; | |
| 40 | - | |
| 41 | - wp_nonce_field('save', 'mbsocial_save'); | |
| 36 | + $content_blocks = isset($args['args']['content_blocks']) ? $args['args']['content_blocks'] : array(); | |
| 37 | + | |
| 38 | + if ( ! is_array($content_blocks) || count($content_blocks) == 0) | |
| 39 | + return; | |
| 40 | + | |
| 41 | + wp_nonce_field('save', 'mbsocial_save'); | |
| 42 | 42 | wp_enqueue_style('mbsocial-global'); |
| 43 | 43 | |
| 44 | - | |
| 45 | - foreach($content_blocks as $index => $item) | |
| 44 | + | |
| 45 | + foreach($content_blocks as $index => $item) | |
| 46 | 46 | { |
| 47 | - $icon = $item['icon']; | |
| 48 | - $title = $item['title']; | |
| 49 | - $content = $item['content']; | |
| 47 | + $icon = $item['icon']; | |
| 48 | + $title = $item['title']; | |
| 49 | + $content = $item['content']; | |
| 50 | + | |
| 51 | + echo "<p><strong> <span class='fa $icon'></span> $title </strong></p> <div class='meta_box_content'> $content </div> "; | |
| 52 | + } | |
| 53 | + | |
| 54 | +} | |
| 50 | 55 | |
| 51 | - echo "<p><strong> <span class='fa $icon'></span> $title </strong></p> <div class='meta_box_content'> $content </div> "; | |
| 52 | - } | |
| 53 | 56 | |
| 54 | -} | |