function tx_add_build_mode_button_to_toolbar() { $isOnepage = onepager()->content()->isOnepage(); $isLiveMode = onepager()->content()->isBuildMode(); if ($isOnepage && !$isLiveMode) { $url = getOpBuildModeUrl(getCurrentPageURL(), true); onepager()->toolbar()->addMenu('op-enable-livemode', $url, '<span class="fa fa-circle"></span> Enable Build Mode'); } //hide the navbar when livemode if ($isLiveMode) { show_admin_bar(false); } }
function onepager_localize_script_data($pageId) { $onepager = onepager(); $ajaxUrl = $onepager->api()->getAjaxUrl(); $nav_arr = $onepager->content()->getMenus(); $cat_arr = $onepager->content()->getCategories(); $pages_arr = $onepager->content()->getPages(); $blocks = array_values((array) $onepager->blockManager()->all()); $groupOrder = $onepager->blockManager()->getGroupOrder(); $sections = array_map(function ($section) { $section = onepager()->render()->sectionBlockDataMerge($section); $section['content'] = onepager()->render()->section($section); $section['style'] = onepager()->render()->style($section); return $section; }, onepager()->section()->getAllValid($pageId)); $footer_markup = get_editor_section_list_footer(); $disableUrl = getOpBuildModeUrl(getCurrentPageURL(), false); return array('ajaxUrl' => $ajaxUrl, 'optionPanel' => onepager()->optionsPanel("onepager")->getOptions(), 'options' => get_option('onepager'), 'page' => 'onepager', 'blocks' => $blocks, 'pageId' => $pageId, 'sections' => $sections, 'menus' => $nav_arr, 'pages' => $pages_arr, 'categories' => $cat_arr, 'groupOrder' => $groupOrder, 'footer' => $footer_markup, 'disable' => $disableUrl, 'presets' => Onepager::getPresets(), 'basePreset' => Onepager::getBasePreset(), 'config' => getOnepagerConfig()); }
require_once 'functions.php'; // command to run launcher (phantomjs or slimerjs) in console/terminal define('EXPORT_LAUNCHER', 'phantomjs'); // command to check accessibility of the launcher in console/terminal // must give some not empty output define('EXPORT_LAUNCHER_VERIFIER', 'phantomjs --version'); // path to ImageMagick bin folder //define('IMGK_PATH', '/usr/local/bin/'); define('IMGK_PATH', ''); // path where temporary HTML and resulting PNG/PDF files will be created //define('OUTPUT_PATH', '/some/folder'); define('OUTPUT_PATH', dirname(__FILE__)); // if you change OUTPUT_PATH then URL string pointing to that folder should be placed here. // By default it's set to this script URL w/o 'server.php' ending //define('OUTPUT_URL', 'http://localhost/somefolder/'); define('OUTPUT_URL', getCurrentPageURL(true)); try { if (!isset($_POST['html'])) { throw new Exception('Error in request data.'); } // get request parameters $html = json_decode($_POST['html'], true); $format = stripslashes($_POST['format']); $orientation = stripslashes($_POST['orientation']); $range = stripslashes($_POST['range']); $fileFormat = stripslashes($_POST['fileFormat']); // generate name of the created single PDF file $out = $range . buildUniqueFileName('-exportedPanel', '.') . $fileFormat; // output file full path $outputFilePath = OUTPUT_PATH . "/{$out}"; // output file URL
<?php //DASHBOARD if (is_admin()) { onepager()->menu()->add('onepager', 'Onepager', 'WordPress Onepager', 'App\\Controllers\\AdminMenuController@getIndex', onepager()->url('resources/images/dashicon-onepager.svg')); } //LIVE MODE TOOLBAR add_action('wp', function () { $url = League\Url\Url::createFromUrl(getCurrentPageURL()); $query = $url->getQuery(); if (onepager()->content()->isLiveMode()) { $query->modify(array('livemode' => false)); onepager()->toolbar()->addMenu('op-disable-livemode', $url, '<span class="fa fa-circle"></span> Disable Build Mode</span>'); onepager()->toolbar()->addMenu('op-add-block', '', '<span class="fa fa-plus"></span> Add Block'); } else { if (!onepager()->content()->isOnepage()) { return; } $query->modify(array('livemode' => true)); onepager()->toolbar()->addMenu('op-enable-livemode', $url, '<span class="fa fa-circle"></span> Enable Build Mode'); } }); //inject onepager add_filter('the_content', function ($content) { $pageId = onepager()->content()->getCurrentPageId(); if (onepager()->content()->isLiveMode()) { return '<div class="wrap"> <div id="onepager-mount"></div> </div>'; } if (onepager()->content()->isOnepage()) { $sections = onepager()->section()->all($pageId); return onepager()->render()->sections($sections);