| Server IP : 68.183.124.220 / Your IP : 216.73.216.141 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/popup-builder/com/classes/ |
Upload File : |
<?php
namespace sgpb;
class MediaButton
{
private $hideMediaButton = true;
public function __toString()
{
return $this->render();
}
public function __construct($hideMediaButton = true)
{
$this->hideMediaButton = $hideMediaButton;
}
public static function allowToShow()
{
global $pagenow, $typenow;
$allowToShow = false;
$pages = array(
'page.php',
'post-new.php',
'post-edit.php',
'widgets.php'
);
$checkPage = in_array(
$pagenow,
$pages
);
// for show in plugins page when package is pro
if (SGPB_POPUP_PKG !== SGPB_POPUP_PKG_FREE) {
array_push($pages, 'post.php');
}
return ($pages && $typenow != 'download');
}
private function allowToShowJsVariable()
{
return get_post_type() == SG_POPUP_POST_TYPE;
}
public function render()
{
if (!$this->hideMediaButton && $this->allowToShowJsVariable()) {
return '';
}
$output = $this->mediaButton();
$output .= $this->insertJsVariable();
return $output;
}
private function insertJsVariable()
{
if (!$this->allowToShowJsVariable()){
return '';
}
$buttonTitle = __('Insert custom JS variable', SG_POPUP_TEXT_DOMAIN);
ob_start();
@include(SG_POPUP_VIEWS_PATH.'jsVariableView.php');
$jsVariableContent = ob_get_contents();
ob_end_clean();
$img = '<span class="dashicons dashicons-welcome-widgets-menus" style="padding: 3px 2px 0px 0px"></span>';
$output = '<a data-id="sgpb-js-variable-wrapper" href="javascript:void(0);" class="button sgpb-insert-js-variable" title="'.$buttonTitle.'" style="padding-left: .4em;">'. $img.$buttonTitle.'</a>';
if (!$this->hideMediaButton) {
$output = '';
}
return $output.$jsVariableContent;
}
private function mediaButton()
{
$allowToShow = MediaButton::allowToShow();
if (!$allowToShow) {
$output = '';
return $output;
}
$currentPostType = AdminHelper::getCurrentPostType();
if (!empty($currentPostType) && $currentPostType == SG_POPUP_POST_TYPE) {
add_action('admin_footer', function() {
require_once(SG_POPUP_VIEWS_PATH.'htmlCustomButtonElement.php');
});
}
ob_start();
@include(SG_POPUP_VIEWS_PATH.'mediaButton.php');
$mediaButtonContent = ob_get_contents();
ob_end_clean();
$showCurrentUser = AdminHelper::showMenuForCurrentUser();
if (!$showCurrentUser) {
return '';
}
$buttonTitle = __('Insert popup', SG_POPUP_TEXT_DOMAIN);
$img = '<span class="dashicons dashicons-welcome-widgets-menus" style="padding: 3px 2px 0px 0px"></span>';
$output = '<a data-id="sgpb-hidden-media-popup" href="javascript:void(0);" class="button sgpb-insert-media-button-js" title="'.$buttonTitle.'" style="padding-left: .4em;">'. $img.$buttonTitle.'</a>';
if (!$this->hideMediaButton) {
$output = '';
}
return $output.$mediaButtonContent;
}
}