Advertisement
zumixosan

WhatsApp Share 2

Oct 23rd, 2019
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.94 KB | None | 0 0
  1. <style>
  2.  
  3. .wpw-color-picker {display: block !important;}
  4.  
  5. </style>
  6.  
  7. <div class="wrap">
  8.  
  9. <div id="icon-options-general" class="icon32"></div>
  10.  
  11. <h1>Whatsapp Share Settings</h1><?php
  12.  
  13.     //we check if the page is visited by click on the tabs or on the menu button.
  14.  
  15.     //then we get the active tab.
  16.  
  17.     $active_tab = "general-options";
  18.  
  19.     if(!empty($_GET["tab"]) && $_GET["tab"] == "whatsapp-options")
  20.  
  21.     {
  22.  
  23.         $active_tab = "whatsapp-options";
  24.  
  25.     }
  26.  
  27. ?>
  28.  
  29. <!-- wordpress provides the styling for tabs. -->
  30.  
  31. <h2 class="nav-tab-wrapper">
  32.  
  33.     <!-- when tab buttons are clicked we jump back to the same page but with a new parameter that represents the clicked tab. accordingly we make it active -->
  34.  
  35.     <a style="cursor:pointer;" data="general-tab-content" class="nav-tab<?php if($active_tab == 'general-options'){echo ' nav-tab-active';} ?> "><?php _e('General Settings', 'whatsapp-share-for-woocommerce'); ?></a>
  36.  
  37.     <a style="cursor:pointer;" data="whatsapp-tab-content" class="nav-tab<?php if($active_tab == 'whatsapp-options'){echo ' nav-tab-active';} ?>"><?php _e('Whatsapp Settings', 'whatsapp-share-for-woocommerce'); ?></a>
  38.  
  39. </h2>
  40.  
  41. <form method="post" action="" name="<?php echo self::$plugin_slug; ?>">
  42.  
  43. <input type="hidden" name="<?php echo self::$plugin_slug; ?>" value="1"/>
  44.  
  45.        
  46.  
  47.         <table class="wpw_table wpwtabcontent active_content" id="general-tab-content">
  48.  
  49.         <tr>
  50.  
  51.         <td colspan="2">
  52.  
  53.         <?php  
  54.  
  55.             settings_fields("general_section");
  56.  
  57.             do_settings_sections("general-options");
  58.  
  59.         ?>
  60.  
  61.         </td>
  62.  
  63.         </tr>
  64.  
  65.         <tr>
  66.  
  67.             <td width="30%">Enable Sharing?</td>
  68.  
  69.             <td>
  70.  
  71.                 <input type="checkbox" name="enable" <?php echo ($this->get_setting("enable")) ? "checked=checked" : ""; ?> value="1" />
  72.  
  73.             </td>
  74.  
  75.         </tr>
  76.  
  77.         <tr>
  78.  
  79.             <td>Show in blog post/page</td>
  80.  
  81.             <td>
  82.  
  83.                 <select name="enable_in_postpage">
  84.  
  85.                     <option value="0" <?php echo ($this->get_setting("enable_in_postpage") == 0) ? "selected=selected" : ""; ?> >None</option>
  86.  
  87.                     <option value="1" <?php echo ($this->get_setting("enable_in_postpage") == 1) ? "selected=selected" : ""; ?> >Both Posts/Pages</option>
  88.  
  89.                     <option value="2" <?php echo ($this->get_setting("enable_in_postpage") == 2) ? "selected=selected" : ""; ?> >Only Posts</option>
  90.  
  91.                     <option value="3" <?php echo ($this->get_setting("enable_in_postpage") == 3) ? "selected=selected" : ""; ?> >Only Pages</option>
  92.  
  93.                 </select>
  94.  
  95.             </td>
  96.  
  97.         </tr>
  98.  
  99.         <tr>
  100.  
  101.             <td>Button Position for Product</td>
  102.  
  103.             <td>
  104.  
  105.                 <select name="button_pos">
  106.  
  107.                     <option value="0" <?php echo ($this->get_setting("button_pos") == 0) ? "selected=selected" : ""; ?>>Below  Title</option>
  108.  
  109.                     <option value="2" <?php echo ($this->get_setting("button_pos") == 2) ? "selected=selected" : ""; ?>>After Price</option>
  110.  
  111.                     <option value="1" <?php echo ($this->get_setting("button_pos") == 1) ? "selected=selected" : ""; ?>>After Description</option>
  112.  
  113.                     <option value="3" <?php echo ($this->get_setting("button_pos") == 3) ? "selected=selected" : ""; ?>>After Wishlist/Tags</option>
  114.  
  115.                 </select>
  116.  
  117.             </td>
  118.  
  119.         </tr>
  120.  
  121.         <tr>
  122.  
  123.             <td>Button Position in Post/Page</td>
  124.  
  125.             <td>
  126.  
  127.                 <select name="btnpost_post">
  128.  
  129.                     <option value="0" <?php echo ($this->get_setting("btnpost_post") == 0) ? "selected=selected" : ""; ?>>Before Content</option>
  130.  
  131.                     <option value="1" <?php echo ($this->get_setting("btnpost_post") == 1) ? "selected=selected" : ""; ?>>After Content</option>
  132.  
  133.                 </select>
  134.  
  135.             </td>
  136.  
  137.         </tr>
  138.  
  139.  
  140.  
  141.         <tr>
  142.  
  143.             <td>Button Alignment</td>
  144.  
  145.             <td>
  146.  
  147.                 <select name="alignment">
  148.  
  149.                     <option value="left" <?php echo ($this->get_setting("alignment") == "left") ? "selected=selected" : ""; ?> >Left</option>
  150.  
  151.                     <option value="right" <?php echo ($this->get_setting("alignment") == "right") ? "selected=selected" : ""; ?> >Right</option>
  152.  
  153.                     <option value="center" <?php echo ($this->get_setting("alignment") == "center") ? "selected=selected" : ""; ?> >Center</option>
  154.  
  155.                 </select>
  156.  
  157.             </td>
  158.  
  159.         </tr>
  160.  
  161.     </table>
  162.  
  163.     <table class="wpw_table wpwtabcontent " id="whatsapp-tab-content" style="display:none;">
  164.  
  165.         <tr >
  166.  
  167.         <td colspan="2">
  168.  
  169.         <?php  
  170.  
  171.             settings_fields("whatsapp_section");
  172.  
  173.             do_settings_sections("whatsapp-options");    
  174.  
  175.         ?>
  176.  
  177.         </td>
  178.  
  179.         </tr>
  180.  
  181.         <tr>
  182.  
  183.             <td width="30%">Enable WhatsApp Sharing?</td>
  184.  
  185.             <td>
  186.  
  187.                 <input type="checkbox" name="enable_sharing" <?php echo ($this->get_setting("enable_sharing")) ? "checked=checked" : ""; ?> value="1" />
  188.  
  189.             </td>
  190.  
  191.         </tr>      
  192.  
  193.         <tr>           
  194.  
  195.         <td width="30%">Display Button Only on Mobile</td>         
  196.  
  197.             <td>               
  198.  
  199.                 <input type="checkbox" name="only_mobile" <?php echo ($this->get_setting("only_mobile")) ? "checked=checked" : ""; ?> value="1" />             
  200.  
  201.                 <br>               
  202.  
  203.                 if <strong>unchecked</strong>, it will display whatsapp button on desktop (for testing on desktop).        
  204.  
  205.             </td>      
  206.  
  207.         </tr>
  208.  
  209.         <tr>
  210.  
  211.             <td>Share Button Text</td>
  212.  
  213.             <td>
  214.  
  215.                 <input type="text" name="btntext" value="<?php echo $this->get_setting("btntext") ?>" />
  216.  
  217.             </td>
  218.  
  219.         </tr>
  220.  
  221.         <tr>
  222.  
  223.             <td>Button size</td>
  224.  
  225.             <td>
  226.  
  227.                 <select name="size">
  228.  
  229.                     <option value="s" <?php echo ($this->get_setting("size") == "s") ? "selected=selected" : ""; ?> >Small</option>
  230.  
  231.                     <option value="m" <?php echo ($this->get_setting("size") == "m") ? "selected=selected" : ""; ?> >Medium</option>
  232.  
  233.                     <option value="l" <?php echo ($this->get_setting("size") == "l") ? "selected=selected" : ""; ?> >Large</option>
  234.  
  235.                 </select>
  236.  
  237.             </td>
  238.  
  239.         </tr>
  240.  
  241.         <tr>
  242.  
  243.             <td>Whatsapp Icon Color</td>
  244.  
  245.             <td>
  246.  
  247.                 <select name="iconcolor">
  248.  
  249.                     <option value="w" <?php echo ($this->get_setting("iconcolor") == "w") ? "selected=selected" : ""; ?> >White</option>
  250.  
  251.                     <option value="b" <?php echo ($this->get_setting("iconcolor") == "b") ? "selected=selected" : ""; ?> >Black</option>
  252.  
  253.                 </select>
  254.  
  255.             </td>
  256.  
  257.         </tr>
  258.  
  259.         <tr>
  260.  
  261.             <td>Transparent Button</td>
  262.  
  263.             <td>
  264.  
  265.                 <select name="transparent">
  266.  
  267.                     <option value="n" <?php echo ($this->get_setting("transparent") == "n") ? "selected=selected" : ""; ?> >No</option>
  268.  
  269.                     <option value="y" <?php echo ($this->get_setting("transparent") == "y") ? "selected=selected" : ""; ?> >Yes</option>
  270.  
  271.                 </select>
  272.  
  273.             </td>
  274.  
  275.         </tr>
  276.  
  277.         <tr>
  278.  
  279.             <td>Description Limit</td>
  280.  
  281.             <td>
  282.  
  283.                 <input type="number" size="3" name="limit" value="<?php echo $this->get_setting("limit"); ?>" />
  284.  
  285.             </td>
  286.  
  287.         </tr>
  288.  
  289.         <tr>
  290.  
  291.             <td>Product Message Template</td>
  292.  
  293.             <td>
  294.  
  295.                 <select name="product_message_template" id="product_message_template">
  296.  
  297.                     <option value="" <?php echo ($this->get_setting("product_message_template") == "0") ? "selected=selected" : ""; ?>
  298.  
  299.                     data="">--Select--</option>
  300.  
  301.                     <option value="1" <?php echo ($this->get_setting("product_message_template") == "1") ? "selected=selected" : ""; ?> data="Hey,
  302.  
  303. i Have found  [product-title],
  304.  
  305. of just [product-price] [product-saleprice]
  306.  
  307. [product-description]">Hey,
  308.  
  309. i Have found  [product-title],
  310.  
  311. of just [product-price] [product-saleprice]
  312.  
  313. [product-description]</option>
  314.  
  315.                     <option value="2" <?php echo ($this->get_setting("product_message_template") == "2") ? "selected=selected" : ""; ?> data="Hi Dear,
  316.  
  317. Look at this  [product-title],
  318.  
  319. just [product-price] [product-saleprice]
  320.  
  321. [product-description]">Hi Dear,
  322.  
  323. Look at this  [product-title],
  324.  
  325. just [product-price] [product-saleprice]
  326.  
  327. [product-description]</option>
  328.  
  329.                     <option value="3" <?php echo ($this->get_setting("product_message_template") == "3") ? "selected=selected" : ""; ?> data="Wow,
  330.  
  331. i found  [product-title],
  332.  
  333. of just [product-price] [product-saleprice]
  334.  
  335. [product-description]">Wow,
  336.  
  337. i found  [product-title],
  338.  
  339. of just [product-price] [product-saleprice]
  340.  
  341. [product-description]</option>
  342.  
  343.                 </select>
  344.  
  345.             </td>
  346.  
  347.         </tr>
  348.  
  349.         <tr>
  350.  
  351.             <td>Share Message For Product</td>
  352.  
  353.             <td>
  354.  
  355.                 <textarea id="product_share_message" name="product_share_message" cols="35" rows="5"><?php echo $this->get_setting("product_share_message"); ?></textarea>
  356.  
  357.                 <br>
  358.  
  359.                 You can use <strong>[product-title]</strong>, <strong>[product-description]</strong> and <strong>[product-price]</strong>, <strong>[product-saleprice]</strong> <br>for display product title,description, regular price and sale price in share message.
  360.  
  361.             </td>
  362.  
  363.         </tr>
  364.  
  365.         <tr>
  366.  
  367.             <td>Template for Message For Post/Page</td>
  368.  
  369.             <td>
  370.  
  371.                 <select name="postpage_share_template" id="postpage_share_template">
  372.  
  373.                     <option value="" <?php echo ($this->get_setting("postpage_share_template") == "0") ? "selected=selected" : ""; ?>
  374.  
  375.                     data="">--Select--</option>
  376.  
  377.                     <option value="1" <?php echo ($this->get_setting("postpage_share_template") == "1") ? "selected=selected" : ""; ?> data="Hi,
  378.  
  379. i have found [title]
  380.  
  381. [description]">Hi,
  382.  
  383. i have found [title]
  384.  
  385. [description]</option>
  386.  
  387.                     <option value="2" <?php echo ($this->get_setting("postpage_share_template") == "2") ? "selected=selected" : ""; ?> data="Wow,
  388.  
  389. Amazing Post [title]
  390.  
  391. [description]">Wow,
  392.  
  393. Amazing Post [title]
  394.  
  395. [description]</option>
  396.  
  397.                     <option value="3" <?php echo ($this->get_setting("postpage_share_template") == "3") ? "selected=selected" : ""; ?> data="Dear,
  398.  
  399. Look What i found, [title]
  400.  
  401. [description]">Dear,
  402.  
  403. Look What i found, [title]
  404.  
  405. [description]</option>
  406.  
  407.                 </select>
  408.  
  409.             </td>
  410.  
  411.         </tr>
  412.  
  413.         <tr>
  414.  
  415.             <td>Share Message For Post/Page</td>
  416.  
  417.             <td>
  418.  
  419.                 <textarea name="postpage_share_message" id="postpage_share_message" cols="35" rows="5"><?php echo $this->get_setting("postpage_share_message"); ?></textarea>
  420.  
  421.                 <br>
  422.  
  423.                 You can use <strong>[title]</strong> and <strong>[description]</strong><br>for display post title and description in share message.
  424.  
  425.             </td>
  426.  
  427.         </tr>
  428.  
  429.     </table>
  430.  
  431.     <?php
  432.  
  433.         /*if(!empty($_GET["tab"]) && $_GET["tab"] == "whatsapp-options")
  434.  
  435.         {
  436.  
  437.             settings_fields("whatsapp_section");
  438.  
  439.             do_settings_sections("whatsapp-options");      
  440.  
  441.         } else {
  442.  
  443.             settings_fields("general_section");
  444.  
  445.             do_settings_sections("general-options");
  446.  
  447.         }*/
  448.  
  449.         submit_button('Save Settings','button button-primary','wpw-submit');
  450.  
  451.     ?>          
  452.  
  453. </form>
  454.  
  455. </div>
  456.  
  457. <script>
  458.  
  459. jQuery('.nav-tab-wrapper a.nav-tab').click(function(){
  460.  
  461.   jQuery('.nav-tab-wrapper a.nav-tab').removeClass('nav-tab-active');
  462.  
  463.   jQuery(this).addClass('nav-tab-active');
  464.  
  465.   jQuery('.wpw_table').hide();
  466.  
  467.   jQuery('#'+jQuery(this).attr('data')).show();
  468.  
  469.    
  470.  
  471.   jQuery('#product_message_template').on('change',function(){
  472.  
  473.     jQuery('#product_share_message').val(jQuery("#product_message_template option:selected").attr('data'));
  474.  
  475.   });
  476.  
  477.  
  478.  
  479.    jQuery('#postpage_share_template').on('change',function(){
  480.  
  481.     jQuery('#postpage_share_message').val(jQuery("#postpage_share_template option:selected").attr('data'));
  482.  
  483.   });
  484.  
  485.  
  486.  
  487. })
  488.  
  489. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement