pryley /
pollux
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace GeminiLabs\Pollux; |
||||
| 4 | |||||
| 5 | use GeminiLabs\Pollux\Application; |
||||
| 6 | use GeminiLabs\Pollux\Config\Config; |
||||
| 7 | use GeminiLabs\Pollux\Helper; |
||||
| 8 | use GeminiLabs\Pollux\PostType\Archive; |
||||
| 9 | use GeminiLabs\Pollux\Settings\Settings; |
||||
| 10 | use WP_Screen; |
||||
| 11 | |||||
| 12 | class Controller |
||||
| 13 | { |
||||
| 14 | /** |
||||
| 15 | * @var Application |
||||
| 16 | */ |
||||
| 17 | protected $app; |
||||
| 18 | |||||
| 19 | public function __construct( Application $app ) |
||||
| 20 | { |
||||
| 21 | $this->app = $app; |
||||
| 22 | } |
||||
| 23 | |||||
| 24 | /** |
||||
| 25 | * @return array |
||||
| 26 | * @filter plugin_action_links_pollux/pollux.php |
||||
| 27 | */ |
||||
| 28 | public function filterPluginLinks( array $links ) |
||||
| 29 | { |
||||
| 30 | $settings_url = admin_url( sprintf( 'options-general.php?page=%s', $this->app->id )); |
||||
| 31 | $links[] = $this->app->config->disable_config |
||||
| 32 | ? sprintf( '<span class="network_only">%s</span>', __( 'Settings Disabled', 'pollux' )) |
||||
| 33 | : sprintf( '<a href="%s">%s</a>', $settings_url, __( 'Settings', 'pollux' )); |
||||
| 34 | return $links; |
||||
| 35 | } |
||||
| 36 | |||||
| 37 | /** |
||||
| 38 | * @return void |
||||
| 39 | * @filter admin_footer_text |
||||
| 40 | */ |
||||
| 41 | public function filterWordPressFooter( $text ) |
||||
| 42 | { |
||||
| 43 | if( $this->app->config->remove_wordpress_footer )return; |
||||
| 44 | return $text; |
||||
| 45 | } |
||||
| 46 | |||||
| 47 | /** |
||||
| 48 | * @return void |
||||
| 49 | * @action admin_enqueue_scripts |
||||
| 50 | */ |
||||
| 51 | public function registerAssets() |
||||
| 52 | { |
||||
| 53 | $screen = Helper::getCurrentScreen(); |
||||
| 54 | |||||
| 55 | $this->registerArchiveAssets( $screen ); |
||||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
| 56 | $this->registerCodemirrorAssets( $screen ); |
||||
|
0 ignored issues
–
show
It seems like
$screen can also be of type stdClass; however, parameter $screen of GeminiLabs\Pollux\Contro...isterCodemirrorAssets() does only seem to accept WP_Screen, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 57 | $this->registerGateKeeperAssets( $screen ); |
||||
|
0 ignored issues
–
show
It seems like
$screen can also be of type stdClass; however, parameter $screen of GeminiLabs\Pollux\Contro...isterGateKeeperAssets() does only seem to accept WP_Screen, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 58 | $this->registerSettingsAssets( $screen ); |
||||
|
0 ignored issues
–
show
It seems like
$screen can also be of type stdClass; however, parameter $screen of GeminiLabs\Pollux\Contro...egisterSettingsAssets() does only seem to accept WP_Screen, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 59 | |||||
| 60 | wp_enqueue_style( 'pollux/main.css', |
||||
| 61 | $this->app->url( 'assets/main.css' ), |
||||
| 62 | apply_filters( 'pollux/enqueue/css/deps', [] ), |
||||
| 63 | $this->app->version |
||||
| 64 | ); |
||||
| 65 | wp_enqueue_script( 'pollux/main.js', |
||||
| 66 | $this->app->url( 'assets/main.js' ), |
||||
| 67 | apply_filters( 'pollux/enqueue/js/deps', [] ), |
||||
| 68 | $this->app->version |
||||
| 69 | ); |
||||
| 70 | wp_localize_script( 'pollux/main.js', |
||||
| 71 | apply_filters( 'pollux/enqueue/js/localize/name', $this->app->id ), |
||||
| 72 | ['vars' => apply_filters( 'pollux/enqueue/js/localize/variables', [] )] |
||||
| 73 | ); |
||||
| 74 | } |
||||
| 75 | |||||
| 76 | /** |
||||
| 77 | * @return void |
||||
| 78 | * @action admin_init |
||||
| 79 | */ |
||||
| 80 | public function removeDashboardWidgets() |
||||
| 81 | { |
||||
| 82 | if( !$this->app->config->remove_dashboard_widgets )return; |
||||
| 83 | $widgets = apply_filters( 'pollux/dashoard/widgets', [ |
||||
| 84 | 'dashboard_primary', |
||||
| 85 | 'dashboard_quick_press', |
||||
| 86 | ]); |
||||
| 87 | foreach( $widgets as $widget ) { |
||||
| 88 | remove_meta_box( $widget, 'dashboard', 'normal' ); |
||||
| 89 | } |
||||
| 90 | } |
||||
| 91 | |||||
| 92 | /** |
||||
| 93 | * @return void |
||||
| 94 | * @action wp_before_admin_bar_render |
||||
| 95 | */ |
||||
| 96 | public function removeWordPressMenu() |
||||
| 97 | { |
||||
| 98 | if( !$this->app->config->remove_wordpress_menu )return; |
||||
| 99 | global $wp_admin_bar; |
||||
| 100 | $wp_admin_bar->remove_menu( 'wp-logo' ); |
||||
| 101 | } |
||||
| 102 | |||||
| 103 | /** |
||||
| 104 | * @return void |
||||
| 105 | */ |
||||
| 106 | protected function registerArchiveAssets( WP_Screen $screen ) |
||||
| 107 | { |
||||
| 108 | if( Helper::endsWith( '_archive', $screen->id ) && $screen->pagenow == 'edit.php' ) { |
||||
| 109 | wp_enqueue_script( 'common' ); |
||||
| 110 | wp_enqueue_script( 'editor-expand' ); |
||||
| 111 | wp_enqueue_script( 'post' ); |
||||
| 112 | wp_enqueue_script( 'postbox' ); |
||||
| 113 | wp_enqueue_script( 'wp-lists' ); |
||||
| 114 | if( wp_is_mobile() ) { |
||||
| 115 | wp_enqueue_script( 'jquery-touch-punch' ); |
||||
| 116 | } |
||||
| 117 | } |
||||
| 118 | } |
||||
| 119 | |||||
| 120 | /** |
||||
| 121 | * @return void |
||||
| 122 | */ |
||||
| 123 | protected function registerCodemirrorAssets( WP_Screen $screen ) |
||||
| 124 | { |
||||
| 125 | if( $screen->id != 'settings_page_pollux' || $screen->pagenow != 'options-general.php' )return; |
||||
| 126 | wp_enqueue_style( 'pollux/codemirror.css', |
||||
| 127 | $this->app->url( 'assets/codemirror.css' ), |
||||
| 128 | [], |
||||
| 129 | $this->app->version |
||||
| 130 | ); |
||||
| 131 | wp_enqueue_script( 'pollux/codemirror.js', |
||||
| 132 | $this->app->url( 'assets/codemirror.js' ), |
||||
| 133 | ['pollux/main.js'], |
||||
| 134 | $this->app->version |
||||
| 135 | ); |
||||
| 136 | } |
||||
| 137 | |||||
| 138 | /** |
||||
| 139 | * @return void |
||||
| 140 | */ |
||||
| 141 | protected function registerGateKeeperAssets( WP_Screen $screen ) |
||||
| 142 | { |
||||
| 143 | if( $screen->id == 'settings_page_pollux' |
||||
| 144 | && $screen->pagenow == 'options-general.php' |
||||
| 145 | && $this->app->gatekeeper->hasPendingDependencies() ) { |
||||
| 146 | wp_enqueue_script( 'updates' ); |
||||
| 147 | } |
||||
| 148 | } |
||||
| 149 | |||||
| 150 | /** |
||||
| 151 | * @return void |
||||
| 152 | */ |
||||
| 153 | protected function registerSettingsAssets( WP_Screen $screen ) |
||||
| 154 | { |
||||
| 155 | if( $screen->id == sprintf( 'toplevel_page_%s', Settings::id() )) { |
||||
| 156 | wp_enqueue_script( 'common' ); |
||||
| 157 | wp_enqueue_script( 'postbox' ); |
||||
| 158 | wp_enqueue_script( 'wp-lists' ); |
||||
| 159 | } |
||||
| 160 | } |
||||
| 161 | } |
||||
| 162 |