コード例 #1
0
ファイル: SGMB.php プロジェクト: mfojtik/elisinwonderland
    public function mediaButtonThickboxs()
    {
        ?>
		<script type="text/javascript">
			jQuery(document).ready(function ($) {
				$('#sgmb-insert').on('click', function () {
					var id = $('#sgmb-buttons-id').val();
					if ('' === id) {
						alert('Select your social media buttons');
						return;
					}
					selectionText = '';
					if (typeof(tinyMCE.editors.content) != "undefined") {
						selectionText = (tinyMCE.activeEditor.selection.getContent()) ? tinyMCE.activeEditor.selection.getContent() : '';
					}
					window.send_to_editor('[sgmb id="' + id + '"]');
					$('#sgmb-thickbox').dialog( "close" );
				});
			});
		</script>
		<div id="sgmb-thickbox" style="display: none;">
			<div class="wrap">
				<p>Insert the shortcode for showing a Social Media.</p>
				<div>
					<select id="sgmb-buttons-id" style="width:150px; margin-bottom:20px;">
						<option value="">Please select...</option>
						<?php 
        global $wpdb;
        $proposedTypes = array();
        $orderBy = 'id DESC';
        $allButtons = SGMBButton::findAll($orderBy);
        foreach ($allButtons as $allButton) {
            ?>
								<option value="<?php 
            echo esc_attr($allButton->getId());
            ?>
"><?php 
            echo esc_html($allButton->getTitle());
            ?>
</option>;
							<?php 
        }
        ?>
					</select>
				</div>
				<div class="sgmb-image-uploader-wrapper">
					<input id="sgmb-upload-image" type="text" style="width:150px;" name="ad_image" value=""
						<?php 
        if (SGMB_PRO != 1) {
            ?>
 disabled <?php 
        }
        ?>
					>
					<input id="sgmb-upload-image-button" class="button" type="button" value="Select custom image"
						<?php 
        if (SGMB_PRO != 1) {
            ?>
 disabled <?php 
        }
        ?>
					>
					<?php 
        if (SGMB_PRO != 1) {
            ?>
						<a href="<?php 
            echo SGMB_PRO_URL;
            ?>
" target="_blank" style="font-size: 24px; font-family: Cursive; font-style: oblique; margin-left: 24px; color: red !important; margin-bottom: 14px !important;">PRO</a>
					<?php 
        }
        ?>
				</div>
				<p class="submit">
					<input type="button" id="sgmb-insert" class="button-primary dashicons-share" value="Insert"/>
					<a class="button-secondary" onclick="jQuery('#sgmb-thickbox').dialog('close')"; title="Cancel">Cancel</a>
				</p>
			</div>
		</div>
	<?php 
    }
コード例 #2
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;
 }
コード例 #3
0
 private static function buttonObjectFromArray($arr, $obj = null)
 {
     $jsonData = json_decode($arr['options'], true);
     if ($obj === null) {
         $obj = new SGMBButton();
     }
     $obj->setTitle($arr['title']);
     $obj->setOptions($arr['options']);
     if (@$arr['id']) {
         $obj->setId($arr['id']);
     }
     return $obj;
 }
コード例 #4
0
    public function form($instance)
    {
        $data = SGMBButton::getDataList();
        ?>

	<p>
	<label for="<?php 
        echo $this->get_field_id('id');
        ?>
"><?php 
        _e('Title:');
        ?>
</label>
	<select  class ="widefat" id="<?php 
        echo $this->get_field_id('id');
        ?>
" name="<?php 
        echo $this->get_field_name('id');
        ?>
">
	<?php 
        for ($i = 0; $i < count($data); $i++) {
            ?>
		<option value="<?php 
            echo @$data[$i]['id'];
            ?>
"
	 	<?php 
            if (@$data[$i]['id'] == @$instance['id']) {
                @($title = @$data[$i]['title']);
                ?>
		selected
	    <?php 
            }
            ?>
	 	> <?php 
            echo @$data[$i]['title'];
            ?>
		</option>
	<?php 
        }
        ?>
	</select>
	<input  id="<?php 
        echo $this->get_field_id('title');
        ?>
" type="hidden" value="<?php 
        echo esc_attr(@$title);
        ?>
" />
	</p>

	<?php 
    }