/** * Callback to register and add sections and settings */ public function admin_init() { // show version if yii was loaded if (!empty($_GET['page']) && $_GET['page'] == 'yii_embed_settings' && YiiEmbed::yiiVersion()) { do_action('yii_embed_admin_notice', strtr(__('<p>Detected Yii Framework :version, Yii-Haw!</p>'), array(':version' => YiiEmbed::yiiVersion()))); } // register the setting and validation callback register_setting('yii_embed', 'yii_embed', array($this, 'validate')); // yii settings add_settings_section('yii', '', array($this, 'settings_section_yii'), 'yii_embed_settings'); add_settings_field('yii_embed_yii_path', __('Yii Path'), array($this, 'settings_field_yii_path'), 'yii_embed_settings', 'yii'); // admin bootstrap settings add_settings_section('admin_bootstrap', '', array($this, 'settings_section_admin_bootstrap'), 'yii_embed_settings'); add_settings_field('yii_embed_admin_bootstrap_css', __('Bootstrap CSS'), array($this, 'settings_field_admin_bootstrap_css'), 'yii_embed_settings', 'admin_bootstrap'); add_settings_field('yii_embed_admin_bootstrap_css_responsive', __('Bootstrap Responsive CSS'), array($this, 'settings_field_admin_bootstrap_css_responsive'), 'yii_embed_settings', 'admin_bootstrap'); add_settings_field('yii_embed_admin_bootstrap_js', __('Bootstrap JS'), array($this, 'settings_field_admin_bootstrap_js'), 'yii_embed_settings', 'admin_bootstrap'); add_settings_field('yii_embed_admin_bootstrap_js_popover', __('Bootstrap Popover JS'), array($this, 'settings_field_admin_bootstrap_js_popover'), 'yii_embed_settings', 'admin_bootstrap'); add_settings_field('yii_embed_admin_bootstrap_js_tooltip', __('Bootstrap Tooltip JS'), array($this, 'settings_field_admin_bootstrap_js_tooltip'), 'yii_embed_settings', 'admin_bootstrap'); // front bootstrap settings add_settings_section('front_bootstrap', '', array($this, 'settings_section_front_bootstrap'), 'yii_embed_settings'); add_settings_field('yii_embed_front_bootstrap_css', __('Bootstrap CSS'), array($this, 'settings_field_front_bootstrap_css'), 'yii_embed_settings', 'front_bootstrap'); add_settings_field('yii_embed_front_bootstrap_css_responsive', __('Bootstrap Responsive CSS'), array($this, 'settings_field_front_bootstrap_css_responsive'), 'yii_embed_settings', 'front_bootstrap'); add_settings_field('yii_embed_front_bootstrap_js', __('Bootstrap JS'), array($this, 'settings_field_front_bootstrap_js'), 'yii_embed_settings', 'front_bootstrap'); add_settings_field('yii_embed_front_bootstrap_js_popover', __('Bootstrap Popover JS'), array($this, 'settings_field_front_bootstrap_js_popover'), 'yii_embed_settings', 'front_bootstrap'); add_settings_field('yii_embed_front_bootstrap_js_tooltip', __('Bootstrap Tooltip JS'), array($this, 'settings_field_front_bootstrap_js_tooltip'), 'yii_embed_settings', 'front_bootstrap'); }
/** * Download and unzip the Yii Framework. * * @throws Exception */ public function download() { // header $this->output('<style>body{ font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; }</style>'); $this->output('<h1>' . __('Yii Framework Downloader') . '</h1>'); // do the download if (!empty($_GET['force']) || !YiiEmbed::yiiVersion()) { // setup variables $yiiPath = YiiEmbed::yiiPath(); $yiiDownloadUrl = YiiEmbed::yiiDownloadUrl(); $pathinfo = pathinfo($yiiDownloadUrl); $yiiFrameworkPath = $yiiPath . '/framework/'; $yiiFrameworkUnzipPath = $yiiPath . '/' . $pathinfo['filename']; $yiiZipFile = $yiiPath . '/' . $pathinfo['basename']; $yiiZipPath = $pathinfo['filename'] . '/framework/'; // pre cleanup $this->delete($yiiFrameworkPath); $this->delete($yiiFrameworkUnzipPath); $this->delete($yiiZipFile); // download $this->output('<h2>' . __('Downloading') . '</h2><b>' . $yiiDownloadUrl . '</b> - '); $downloaded = $this->downloadChunked($yiiDownloadUrl, $yiiZipFile); if (!$downloaded) { throw new Exception(__('Failed to download.')); } // unzip $this->output('<h2>' . __('Unzipping') . '</h2><b>' . $yiiZipFile . '</b> - '); $files = $this->unzipEntryPath($yiiZipFile, $yiiPath, $yiiZipPath); if (!$files) { throw new Exception(__('Failed to unzip.')); } $this->output(count($files) . ' ' . __('files'), true); // post cleanup rename($yiiFrameworkUnzipPath . '/framework/', $yiiFrameworkPath); $this->delete($yiiFrameworkUnzipPath); $this->delete($yiiZipFile); // output yii version $this->output('<h2>' . __('Success!') . '</h2>'); $this->output(strtr(__('Yii Framework version :version is installed, Yii-Haw!'), array(':version' => YiiEmbed::yiiVersion(true)))); } else { $this->output('<h2>' . strtr(__('Yii Framework :version is already installed'), array(':version' => YiiEmbed::yiiVersion())) . '</h2>'); $this->output('<a href="download.php?force=true">' . __('Force Download') . '</a> | '); } // link back to admin $this->output('<a href="' . get_admin_url() . 'options-general.php?page=yii_embed_settings">' . __('Return to WordPress') . '</a>'); }
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ // do not allow direct entry here if (!function_exists('wp')) { echo 'Yii Embed cannot be called directly.'; exit; } // yii embed constants define('YII_EMBED_VERSION', '1.1.0'); define('YII_EMBED_URL', plugin_dir_url(__FILE__)); define('YII_EMBED_PATH', __DIR__ . '/'); // yii constants defined('YII_DEBUG') or define('YII_DEBUG', WP_DEBUG); // load debug if (YII_DEBUG) { require_once YII_EMBED_PATH . 'includes/debug.php'; require_once YII_EMBED_PATH . 'includes/kint/Kint.class.php'; } // load YiiEmbed and Yii require_once YII_EMBED_PATH . 'includes/YiiEmbed.php'; define('YII_EMBED_YII_VERSION', YiiEmbed::yiiVersion()); YiiEmbed::init();