/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * @return mixed */ public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->check()) { return redirect(addon()->config('addon.routes.landing', '/')); } return $next($request); }
protected function runAdminBootstrapScript() { if (env('WP_MULTISITE', false)) { // for 'wp-includes/ms-functions.php' global $current_site; global $current_blog; // for 'wp-includes/ms-settings.php' global $blog_id; global $wpdb; global $_wp_switched_stack; } else { // no globals } define('WP_CONTENT_URL', addon()->config('wordpress.url.site') . '/wp-content'); require_once wordpress_path('wp-load.php'); // for 'wp-admin/includes/file.php' global $wp_file_descriptions; require_once wordpress_path('wp-admin/includes/admin.php'); // Add .blade.php description $file_descriptions = $wp_file_descriptions; foreach ($wp_file_descriptions as $filename => $description) { if (preg_match('/\\.php$/', $filename)) { $file_descriptions[preg_replace('/\\.php$/', '.blade.php', $filename)] = $description; } } $wp_file_descriptions = $file_descriptions; $this->registerContentNamespaces(); }
/** * Define the routes for the addon. * * @param \Illuminate\Routing\Router $router (injection) * @return void */ public function map(Router $router) { $router->group(['prefix' => addon()->config('wordpress.url.backend_prefix'), 'namespace' => $this->namespace], function ($router) { require __DIR__ . '/../Http/backend-routes.php'; }); $router->group(['prefix' => addon()->config('wordpress.url.site_prefix'), 'namespace' => $this->namespace], function ($router) { require __DIR__ . '/../Http/site-routes.php'; }); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @param string|null $guard * @return mixed */ public function handle($request, Closure $next, $guard = null) { if (Auth::guard($guard)->guest()) { if ($request->ajax() || $request->wantsJson()) { return response('Unauthorized.', 401); } else { return redirect()->guest(addon()->config('addon.routes.login', '/login')); } } return $next($request); }
/** * Define the routes for the addon. * * @param \Illuminate\Routing\Router $router (injection) * @return void */ public function map(Router $router) { $attributes = ['domain' => addon()->config('addon.routes.domain', null), 'prefix' => addon()->config('addon.routes.prefix', ''), 'middleware' => addon()->config('addon.routes.middleware', []), 'namespace' => addon()->config('addon.namespace') . '\\Http\\Controllers']; $files = array_map(function ($file) { return addon()->path($file); }, addon()->config('addon.routes.files', ['classes/Http/routes.php'])); $router->group($attributes, function ($router) use($files) { foreach ($files as $file) { require $file; } }); }
/** * Inject custom stub files. * * @return void */ protected function injectCustomStubs() { $files = $this->app['files']; $stub_directory = addon()->config('commands.stub.directory'); $routine = function ($instance, $app) use($stub_directory) { $instance->setStubDirectory($stub_directory); return $instance; }; if (addon()->config('commands.stub.overrides')) { if ($files->exists($stub_directory . '/console.stub')) { $this->app->extend('command+.console.make', $routine); } if ($files->exists($stub_directory . '/controller.stub')) { $this->app->extend('command+.controller.make', $routine); } if ($files->exists($stub_directory . '/event.stub')) { $this->app->extend('command+.event.make', $routine); } if ($files->exists($stub_directory . '/job.stub')) { $this->app->extend('command+.job.make', $routine); } if ($files->exists($stub_directory . '/listener.stub')) { $this->app->extend('command+.listener.make', $routine); } if ($files->exists($stub_directory . '/middleware.stub')) { $this->app->extend('command+.middleware.make', $routine); } if ($files->exists($stub_directory . '/migration.stub')) { $this->app->extend('command+.migration.make', $routine); } if ($files->exists($stub_directory . '/model.stub')) { $this->app->extend('command+.model.make', $routine); } if ($files->exists($stub_directory . '/policy.stub')) { $this->app->extend('command+.policy.make', $routine); } if ($files->exists($stub_directory . '/provider.stub')) { $this->app->extend('command+.provider.make', $routine); } if ($files->exists($stub_directory . '/request.stub')) { $this->app->extend('command+.request.make', $routine); } if ($files->exists($stub_directory . '/seeder.stub')) { $this->app->extend('command+.seeder.make', $routine); } if ($files->exists($stub_directory . '/test.stub')) { $this->app->extend('command+.test.make', $routine); } } }
public function __construct() { View::share('__addon', addon()); }
public function downloadOnSite(Request $request) { return $this->download($request, addon()->config('wordpress.url.site_prefix')); }
function group($group, $addons) { extract($group); ?> <div class="group" id="<?php print $name; ?> "> <div class="group-title<?php print isset($user_id) ? '' : ' not-selected'; ?> " id="g_<?php print $id; ?> "> <input type="checkbox" <?php print isset($user_id) ? 'checked="checked"' : ''; ?> /> </div> <div class="group-addons"> <?php foreach ($addons as $addon) { if ($addon) { addon($addon); } } ?> </div> </div> <?php }
$router->get('{f1}/{f2}/{f3}/{f4}/{f5}/{f6}/{f7}', $action); $router->get('{f1}/{f2}/{f3}/{f4}/{f5}/{f6}/{f7}/{f8}', $action); $router->get('{f1}/{f2}/{f3}/{f4}/{f5}/{f6}/{f7}/{f8}/{f9}', $action); } } // Login Gate $router->group(['prefix' => ''], function ($router) { // ?action = ['postpass', 'logout', logout', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register'] $router->get('wp-login.php', 'GateController@login'); $router->post('wp-login.php', 'GateController@login'); }); // Shortcuts $router->group(['prefix' => ''], function ($router) { $admin_url = addon()->config('wordpress.url.backend') . '/wp-admin/'; // WordPress+ original routing if (addon()->config('wordpress.url.backend') != addon()->config('wordpress.url.site')) { $router->get('', function () use($admin_url) { return redirect()->to($admin_url); }); } // MEMO from wp_redirect_admin_locations() on 'wp-includes/canonical.php' $router->get('login', 'GateController@login'); $router->get('admin', function () use($admin_url) { return redirect()->to($admin_url); }); $router->get('dashboard', function () use($admin_url) { return redirect()->to($admin_url); }); }); // /wp-admin/network $router->group(['prefix' => 'wp-admin/network'], function ($router) {
/** * 관련된 애드온의 레코드 삭제 * @param string $sModuleCode 모듈코드 * @param array $aSeq 삭제하려는 시퀀스 넘버 */ private function _deleteRelatedAddon($sModuleCode, $aSeq) { $bResult = true; foreach ($aSeq as $iVal) { /* 시퀀스 메뉴 삭제 */ if (addon()->adminmenu()->data()->set()->isUseAdminSeqMenu($sModuleCode)) { /* @var $oAdminMenuDataSet addonAdminmenuDataSet */ $oAdminMenuDataSet = getInstance('addonAdminmenuDataSet'); $bResult = $bResult && $oAdminMenuDataSet->delModuleSeqMenus($sModuleCode, $iVal); } /* 모듈 항목정보를 삭제 */ if (addon()->field()->data()->set()->isUseField($sModuleCode)) { /* @var $oFieldDataSet addonFieldDataSet */ $oFieldDataSet = getInstance('addonFieldDataSet'); $bResult = $bResult && $oFieldDataSet->delete($sModuleCode, $iVal); } /* URL Rewrite 설정 삭제 */ if ($this->hasConf('urlrewrite', $sModuleCode)) { if (addon()->urlrewrite()->config()->sequence()->delete($sModuleCode, $iVal) === false) { $bResult = false; } } /* Category 삭제 */ /* @var $oAddonFieldDataSet addonFieldDataSet */ $oAddonFieldDataSet = getInstance('addonFieldDataSet'); if ($oAddonFieldDataSet->isUseCategory($sModuleCode)) { /* @var $oAddonCategoryManagerData addonCategoryManagerData */ $oAddonCategoryManagerData = getInstance('addonCategoryManagerData'); $bResult = $bResult && $oAddonCategoryManagerData->deleteCategory($iVal, $sModuleCode); } } return $bResult; }
function group($group, $addons) { extract($group); ?> <div class="group" id="<?php print $name; ?> "> <div class="group-title" id="g_<?php print $id; ?> "> <h3><?php print htmlspecialchars($title); ?> </h3> <p><?php print htmlspecialchars($description); ?> </p> </div> <?php if ($addons) { ?> <div class="group-addons"> <?php $i = 0; foreach ($addons as $addon) { if ($addon) { addon($addon, $i); } $i++; } ?> </div> <?php } ?> </div> <?php }
/** * @wp_action template_include */ public function evaluateTemplate($php_path) { debug_log('filter:template_include', basename($php_path)); $dirname = dirname($php_path); $filename = basename($php_path, '.php'); // blade extension $blade_path = $dirname . '/' . addon()->config('wordpress.themes.blade.directory') . '/' . $filename . '.blade.php'; if (file_exists($blade_path)) { if (addon()->config('wordpress.themes.blade.precompile')) { $header_comment = addon()->config('wordpress.themes.blade.header_comment'); $php_script_image = app('blade.expander')->expand($blade_path); // Output php file_put_contents($php_path, "<?php /* {$header_comment} */ ?>\n"); file_put_contents($php_path, $php_script_image, FILE_APPEND); } else { // Output html file_put_contents($php_path, $this->renderBladeTemplate($blade_path)); } } return $php_path; }
/** * Create a new authentication controller instance. * * @return void */ public function __construct() { $this->middleware('guest', ['except' => 'logout']); $this->redirectTo = addon()->config('addon.routes.home', '/home'); }
public function runPhpScript() { $path = app('request')->path(); $prefix = addon()->config('wordpress.url.backend_prefix'); // trim prefix if (starts_with($path, $prefix)) { $path = substr($path, strlen($prefix)); } $path = wordpress_path($path); // ERROR: file not found if (!is_file($path)) { abort(404); } require $path; }