Advertisement
retesere20

example construct - wp plugin

Feb 28th, 2020
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.48 KB | None | 0 0
  1. <?php
  2. /*
  3. * Plugin Name: a-my-custom-plugin
  4. * Description: My custom plugin
  5. * Text Domain: a-my-custom-plugin
  6. * Domain Path: /languages
  7. * Version: 1.22
  8. * WordPress URI: https://wordpress.org/plugins/
  9. * Plugin URI: https://puvox.software/wordpress/
  10. * Contributors: puvoxsoftware,ttodua
  11. * Author: puvox.software
  12. * Author URI: https://puvox.software/profile
  13. * Donate Link: https://paypal.me/Puvox
  14. * License: GPL-3.0
  15. * License URI: https://www.gnu.org/licenses/gpl-3.0.html
  16.  
  17. * @copyright: Puvox.software
  18. */
  19.  
  20. namespace PuvoxSoftware
  21. {
  22. if (!defined('ABSPATH')) exit;
  23. //$lib_final=dirname(__DIR__)."/".($name='default_library_puvox.php');
  24. $lib_final=__DIR__."/library/".($name='default_library_puvox_PHP.php');
  25. if( file_exists($lib_start=__DIR__."/$name") && !defined("_puvox_machine_") ) { rename($lib_start, $lib_final); } require_once($lib_final);
  26.  
  27. class PluginClass extends \default_plugin__PuvoxSoftware
  28. {
  29.  
  30. public function declare_settings()
  31. {
  32. $this->initial_static_options =
  33. [
  34. 'has_pro_version' =>0,
  35. 'show_opts' =>true,
  36. 'show_rating_message'=>false,
  37. 'display_tabs' =>false,
  38. 'required_role' =>'install_plugins',
  39. 'default_managed' =>'network', //network, singlesite
  40. ];
  41.  
  42. $this->initial_user_options =
  43. [
  44.  
  45. ];
  46. }
  47.  
  48.  
  49. public function __construct_my()
  50. {
  51. //
  52. $this->helpers->error_to_mailaddress = 'your_mail@gmail.com'; // send errors to email
  53. $this->helpers->enable_write_logs = false; // enable logs writing
  54. $this->helpers->PASSWORD_FOR_SITE = ''; //
  55. $this->helpers->google_analytics_ID = ''; //
  56. $this->helpers->google_tag_manager_ID = ''; //
  57. $this->helpers->top_ge_ID = ''; //
  58. $this->helpers->google_firebase_ID = ''; // https://console.firebase.google.com/project/my-test-proj-fc1cb/overview
  59. $this->helpers->auth_expiration_hours = 444; //
  60. $this->helpers->posts_per_page = 20; //
  61. $this->helpers->search_items_amount_in_menu = 20; //
  62. $this->helpers->shortcodes = []; //
  63. $this->helpers->customOptsPageUrl = admin_url().'/.../'; //
  64. $this->helpers->remove_comments_url = true; //
  65. $this->helpers->extend_shortcodes = true; // activates shortcodes: image, video, link, iframe, @, script, video, list_subpages ,
  66. // i.e. [list type="categories" id="32" depth=0 exclude="4,28"]
  67. // i.e. [list type="pages" id="32" depth=0 exclude="4,28"] (or id="this")
  68. // i.e. [list type="menu" id="32"]
  69. $this->helpers->disable_update = true; // disable update for current plugin
  70. $this->add_my_site_options(['smth'=>'value']); // activates extra options page
  71. $this->admin_styles = '<style>.xxx{}</style>';
  72.  
  73. $this->helpers->load_scripts_override =
  74. [
  75. 'jquery' => ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  76. 'js' => '//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js'
  77. ]],
  78. 'jquery-migrate'=> ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  79. 'js' => '//cdnjs.cloudflare.com/ajax/libs/jquery-migrate/3.0.1/jquery-migrate.min.js'
  80. ]],
  81. 'jquery-ui' => ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  82. 'css' =>'//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css',
  83. 'js' => '//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js',
  84. ]],
  85. 'bootstrap' => ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  86. 'css'=> '//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css',
  87. 'js' => '//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js',
  88. ]],
  89. 'less' => ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  90. 'js' => '//cdnjs.cloudflare.com/ajax/libs/less.js/3.9.0/less.min.js',
  91. ]],
  92. 'font-awesome' => ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  93. 'css'=> '//use.fontawesome.com/releases/v5.6.3/css/all.css',
  94. ]],
  95. 'font-awesome-animations1'=> ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  96. 'css'=> '//cdnjs.cloudflare.com/ajax/libs/font-awesome-animation/0.2.1/font-awesome-animation.min.css',
  97. ]], // https://l-lin.github.io/font-awesome-animation/
  98. 'google-fonts' => ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  99. 'css' => '//fonts.googleapis.com/css?family=PT+Sans+Caption:400,700&subset=latin,latin-ext'
  100. ]],
  101. 'fancybox' => ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  102. 'css' => '//cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.css',
  103. 'js' => '//cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.js',
  104. ]], // http://fancyapps.com/fancybox/
  105. 'animate' => ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  106. 'css' => '//cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css',
  107. 'js' => '//cdnjs.cloudflare.com/ajax/libs/animateCSS/1.2.2/jquery.animatecss.min.js',
  108. ]], //https://codepen.io/strapro/pen/dIqAH https://daneden.github.io/animate.css/
  109. // Example: https://pastebin_com/xwXQLZES
  110.  
  111. 'cookies' => ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  112. 'js' => 'https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.2.0/js.cookie.min.js',
  113. ]],
  114. 'spin' => ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  115. 'js' => '//cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2/spin.min.js',
  116. ]], // http://spin.js.org/
  117. 'hover' => ['screen'=>['admin'=>0, 'public'=>0], 'urls'=>[
  118. 'css' => '//cdnjs.cloudflare.com/ajax/libs/hover.css/2.3.1/css/hover-min.css'
  119. ]], // https://ianlunn.github.io/Hover/
  120.  
  121. 'my_javascript' => ['screen'=>['admin'=>0, 'public'=>0]],
  122. 'my_style_public' => ['screen'=>['admin'=>0, 'public'=>1]],
  123. 'my_style_admin' => ['screen'=>['admin'=>1, 'public'=>0]],
  124. ];
  125.  
  126. //if ($this->helpers->property('add_social_links_options')) add_action('admin_menu', [$this,'funccc413']);
  127. $this->helpers->plugin_reset_callback = function(){}; //
  128. $this->helpers->hooks_examples = function(){}; //
  129.  
  130.  
  131.  
  132. }
  133.  
  134.  
  135. // ============================================================================================================== //
  136. // ============================================================================================================== //
  137.  
  138.  
  139.  
  140.  
  141.  
  142. public function opts_page_output() { $this->settings_page_part("start"); ?>
  143.  
  144. <style>
  145. p.submit { text-align:center; }
  146. .settingsTitle{display:none;}
  147. .myplugin {padding:10px;}
  148. zzz#mainsubmit-button{display:none;}
  149. .plugin-title{text-align:center;}
  150. #icon_or_phrase{width:100%;}
  151. </style>
  152.  
  153. <form class="mainForm" method="post" action="">
  154.  
  155. <?php if ($this->active_tab=="Options") { ?>
  156.  
  157. <?php
  158. //if form updated
  159. if( isset($_POST["_wpnonce"]) && check_admin_referer("nonce_".$this->plugin_slug) )
  160. {
  161. $this->opts = array_merge($this->opts, $this->array_map_recursive('sanitize_file_name', $_POST[ $this->plugin_slug ]) );
  162. $this->opts['icon_or_phrase'] = sanitize_text_field( $_POST[ $this->plugin_slug ]['icon_or_phrase'] );
  163. $this->update_opts();
  164. }
  165.  
  166. return;
  167. ?>
  168.  
  169. <table class="form-table">
  170. <tbody>
  171. <tr class="def">
  172. <th scope="row">
  173. <label for="">
  174. <?php _e('Count logged-in members (editor or above) PAGEVIEW?', 'simple-post-views-count');?>
  175. </label>
  176. </th>
  177. <td>
  178. <?php _e('No', 'simple-post-views-count');?><input type="radio" name="<?php echo $this->plugin_slug;?>[admins_count]" value="no" <?php checked($this->opts[''], "no");?> />
  179. <?php _e('Yes', 'simple-post-views-count');?><input type="radio" name="<?php echo $this->plugin_slug;?>[admins_count]" value="yes" <?php checked($this->opts[''], "yes");?> />
  180. </td>
  181. </tr>
  182. </tbody>
  183. </table>
  184.  
  185. <?php
  186. wp_nonce_field( "nonce_".$this->plugin_slug);
  187. submit_button( false, 'button-primary', '', true, $attrib= array( 'id' => 'mainsubmit-button') );
  188. ?>
  189.  
  190. <?php
  191. } ?>
  192.  
  193. </form>
  194.  
  195. <?php $this->settings_page_part("end");
  196. }
  197.  
  198. public function plugin_reset_callback()
  199. {
  200.  
  201. }
  202.  
  203.  
  204. }
  205.  
  206. $GLOBALS[__NAMESPACE__] = new PluginClass();
  207.  
  208.  
  209. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement