[ Index ] |
PHP Cross Reference of YOURLS |
[Summary view] [Print] [Text view]
1 <?php 2 define( 'YOURLS_ADMIN', true ); 3 require_once( dirname( __DIR__ ).'/includes/load-yourls.php' ); 4 yourls_maybe_require_auth(); 5 6 // Handle plugin administration pages 7 if( isset( $_GET['page'] ) && !empty( $_GET['page'] ) ) { 8 yourls_plugin_admin_page( $_GET['page'] ); 9 die(); 10 } 11 12 // Handle activation/deactivation of plugins 13 if( isset( $_GET['action'] ) ) { 14 15 // Check nonce 16 yourls_verify_nonce( 'manage_plugins', $_REQUEST['nonce'] ?? ''); 17 18 // Check plugin file is valid 19 if(isset( $_GET['plugin'] ) && yourls_is_a_plugin_file(YOURLS_PLUGINDIR . '/' . $_GET['plugin'] . '/plugin.php') ) { 20 21 // Activate / Deactive 22 switch( $_GET['action'] ) { 23 case 'activate': 24 $result = yourls_activate_plugin( $_GET['plugin'].'/plugin.php' ); 25 if( $result === true ) { 26 yourls_redirect(yourls_admin_url('plugins.php?success=activated'), 302); 27 exit(); 28 } 29 break; 30 31 case 'deactivate': 32 $result = yourls_deactivate_plugin( $_GET['plugin'].'/plugin.php' ); 33 if( $result === true ) { 34 yourls_redirect(yourls_admin_url('plugins.php?success=deactivated'), 302); 35 exit(); 36 } 37 break; 38 39 default: 40 $result = yourls__( 'Unsupported action' ); 41 break; 42 } 43 } else { 44 $result = yourls__( 'No plugin specified, or not a valid plugin' ); 45 } 46 47 yourls_add_notice( $result ); 48 } 49 50 // Handle message upon successful (de)activation 51 if( isset( $_GET['success'] ) && ( ( $_GET['success'] == 'activated' ) OR ( $_GET['success'] == 'deactivated' ) ) ) { 52 if( $_GET['success'] == 'activated' ) { 53 $message = yourls__( 'Plugin has been activated' ); 54 } elseif ( $_GET['success'] == 'deactivated' ) { 55 $message = yourls__( 'Plugin has been deactivated' ); 56 } 57 yourls_add_notice( $message ); 58 } 59 60 yourls_html_head( 'plugins', yourls__( 'Manage Plugins' ) ); 61 yourls_html_logo(); 62 yourls_html_menu(); 63 ?> 64 65 <main role="main"> 66 <h2><?php yourls_e( 'Plugins' ); ?></h2> 67 68 <?php 69 $plugins = (array)yourls_get_plugins(); 70 uasort( $plugins, 'yourls_plugins_sort_callback' ); 71 72 $count = count( $plugins ); 73 $plugins_count = sprintf( yourls_n( '%s plugin', '%s plugins', $count ), $count ); 74 $count_active = yourls_has_active_plugins(); 75 ?> 76 77 <p id="plugin_summary"><?php /* //translators: "you have '3 plugins' installed and '1' activated" */ yourls_se( 'You currently have <strong>%1$s</strong> installed, and <strong>%2$s</strong> activated', $plugins_count, $count_active ); ?></p> 78 79 <table id="main_table" class="tblSorter" cellpadding="0" cellspacing="1"> 80 <thead> 81 <tr> 82 <th><?php yourls_e( 'Plugin Name' ); ?></th> 83 <th><?php yourls_e( 'Version' ); ?></th> 84 <th><?php yourls_e( 'Description' ); ?></th> 85 <th><?php yourls_e( 'Author' ); ?></th> 86 <th><?php yourls_e( 'Action' ); ?></th> 87 </tr> 88 </thead> 89 <tbody> 90 <?php 91 92 $nonce = yourls_create_nonce( 'manage_plugins' ); 93 94 foreach( $plugins as $file=>$plugin ) { 95 96 // default fields to read from the plugin header 97 $fields = array( 98 'name' => 'Plugin Name', 99 'uri' => 'Plugin URI', 100 'desc' => 'Description', 101 'version' => 'Version', 102 'author' => 'Author', 103 'author_uri' => 'Author URI' 104 ); 105 106 // Loop through all default fields, get value if any and reset it 107 foreach( $fields as $field=>$value ) { 108 if( isset( $plugin[ $value ] ) ) { 109 $data[ $field ] = $plugin[ $value ]; 110 } else { 111 $data[ $field ] = yourls__('(no info)'); 112 } 113 unset( $plugin[$value] ); 114 } 115 116 $plugindir = trim( dirname( $file ), '/' ); 117 118 if( yourls_is_active_plugin( $file ) ) { 119 $class = 'active'; 120 $action_url = yourls_nonce_url( 'manage_plugins', yourls_add_query_arg( array('action' => 'deactivate', 'plugin' => $plugindir ), yourls_admin_url('plugins.php') ) ); 121 $action_anchor = yourls__( 'Deactivate' ); 122 } else { 123 $class = 'inactive'; 124 $action_url = yourls_nonce_url( 'manage_plugins', yourls_add_query_arg( array('action' => 'activate', 'plugin' => $plugindir ), yourls_admin_url('plugins.php') ) ); 125 $action_anchor = yourls__( 'Activate' ); 126 } 127 128 // Other "Fields: Value" in the header? Get them too 129 if( $plugin ) { 130 foreach( $plugin as $extra_field=>$extra_value ) { 131 $data['desc'] .= "<br/>\n<em>$extra_field</em>: $extra_value"; 132 unset( $plugin[$extra_value] ); 133 } 134 } 135 136 $data['desc'] .= '<br/><small>' . yourls_s( 'plugin file location: %s', $file) . '</small>'; 137 138 printf( "<tr class='plugin %s'><td class='plugin_name'><a href='%s'>%s</a></td><td class='plugin_version'>%s</td><td class='plugin_desc'>%s</td><td class='plugin_author'><a href='%s'>%s</a></td><td class='plugin_actions actions'><a href='%s'>%s</a></td></tr>", 139 $class, $data['uri'], $data['name'], $data['version'], $data['desc'], $data['author_uri'], $data['author'], $action_url, $action_anchor 140 ); 141 142 } 143 ?> 144 </tbody> 145 </table> 146 147 <script type="text/javascript"> 148 yourls_defaultsort = 0; 149 yourls_defaultorder = 0; 150 <?php if ($count_active) { ?> 151 $('#plugin_summary').append('<span id="toggle_plugins">filter</span>'); 152 $('#toggle_plugins').css({'background':'transparent url("../images/filter.svg") top left no-repeat','display':'inline-block','text-indent':'-9999px','width':'16px','height':'16px','margin-left':'3px','cursor':'pointer'}) 153 .attr('title', '<?php echo yourls_esc_attr__( 'Toggle active/inactive plugins' ); ?>') 154 .click(function(){ 155 $('#main_table tr.inactive').toggle(); 156 }); 157 <?php } ?> 158 </script> 159 160 <p><?php yourls_e( 'If something goes wrong after you activate a plugin and you cannot use YOURLS or access this page, simply rename or delete its directory, or rename the plugin file to something different than <code>plugin.php</code>.' ); ?></p> 161 162 <h3><?php yourls_e( 'More plugins' ); ?></h3> 163 164 <p><?php yourls_e( 'For more plugins, head to the official <a href="http://yourls.org/awesome">Plugin list</a>.' ); ?></p> 165 </main> 166 167 <?php yourls_html_footer(); ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sat Feb 22 05:10:06 2025 | Cross-referenced by PHPXref 0.7.1 |