コード例 #1
0
 public function getData($id)
 {
     $data = array();
     $result = SGMBButton::findById($id);
     if ($result) {
         $data['id'] = $result->getId();
         $data['title'] = $result->getTitle();
         $data['options'] = json_decode($result->getOptions(), true);
         $data['buttonOptions'] = json_decode($data['options']['buttons'], true);
         foreach ($data['buttonOptions'] as $key => $value) {
             $data['button'][] = $key;
         }
     }
     return $data;
 }
コード例 #2
0
ファイル: SGMB.php プロジェクト: mfojtik/elisinwonderland
 public function buttonsShowOnEveryPost($content)
 {
     $postID = get_the_ID();
     $id = get_option('SGMB_SHARE_BUTTON_ID');
     $obj = SGMBButton::findById($id);
     if ($obj) {
         $data = json_decode($obj->getOptions(), true);
         $textBeforeSocialMedia = @$data['textOnEveryPost'];
         $postsTitleInData = @$data['sgmbSelectedPosts'];
         switch (@$data['sgmbPostionOnEveryPost']) {
             case 'Left':
                 $sgmbPosition = 'sgmb-left';
                 break;
             case 'Center':
                 $sgmbPosition = 'sgmb-center';
                 break;
             case 'Right':
                 $sgmbPosition = 'sgmb-right';
                 break;
         }
         if (@$data['showButtonsOnEveryPost'] == 'on') {
             if (@$data['showOnAllPost'] == 'on' && !is_page()) {
                 $content .= "<div class = 'socialMediaOnEveryPost'>";
                 $content .= @$textBeforeSocialMedia;
                 $content .= do_shortcode("[sgmb id={$id}]");
                 $content .= "</div>";
                 $content .= '<script> jQuery(".socialMediaOnEveryPost").addClass("' . $sgmbPosition . '") </script>';
             } else {
                 foreach ($postsTitleInData as $postTitleInData) {
                     if (!is_home() && $postID == $postTitleInData) {
                         $content .= "<div class = 'socialMediaOnEveryPost'>";
                         $content .= @$textBeforeSocialMedia;
                         $content .= do_shortcode("[sgmb id={$id}]");
                         $content .= "</div>";
                         $content .= '<script> jQuery(".socialMediaOnEveryPost").addClass("' . $sgmbPosition . '") </script>';
                     }
                 }
             }
         }
     }
     return $content;
 }
コード例 #3
0
 public function getData()
 {
     $data = array();
     if (isset($_GET['id'])) {
         $id = intval(sanitize_text_field($_GET['id']));
         $result = SGMBButton::findById($id);
         if ($result) {
             $data['id'] = $result->getId();
             $data['title'] = $result->getTitle();
             $data['options'] = json_decode($result->getOptions(), true);
             $data['buttonOptions'] = json_decode($data['options']['buttons'], true);
             foreach ($data['buttonOptions'] as $key => $value) {
                 $data['button'][] = $key;
             }
         }
     }
     return $data;
 }