Sunday, September 29, 2019

bootstrap, Modal - How to get Bootstrap Modal's invoke or source element?

How to get Bootstrap Modal invoke or source element?

$('#your-modal').on('show.bs.modal', function (e) {
  var $invoker = $(e.relatedTarget);
});

Various events of modal popup are:


  1. show.bs.modal: fired just before the modal is open.
  2. shown.bs.modal: fired after the modal is shown.
  3. hide.bs.modal: fired just before the modal is hidden.
  4. hidden.bs.modal: fired after the modal is closed.

How to open a Bootstrap modal window using jQuery?


$('#myModal').modal('show') // initializes and invokes show immediately

Bootstrap has a few functions that can be called manually on modals:

$('#myModal').modal('toggle');

You can check more documentation here
https://getbootstrap.com/docs/3.4/javascript/

$('#myModal').modal('show');
$('#myModal').modal('hide');

Wordpress, Gravity form - GFCommon::encrypt() is deprecated since version 2.3! Use GFCommon::openssl_encrypt() instead.

After updating  the gravity form ,I’m receiving a few error messages:

Notice : GFCommon::encrypt() is deprecated since version 2.3! Use GFCommon::openssl_encrypt() instead. in /home4/sunshine/public_html/wp-includes/functions.php on line 4435

Deprecated : Function mcrypt_get_iv_size() is deprecated in /home4/sunshine/public_html/wp-content/plugins/gravityforms/common.php on line 5399

Deprecated : Function mcrypt_create_iv() is deprecated in /home4/sunshine/public_html/wp-content/plugins/gravityforms/common.php on line 5402

Deprecated : Function mcrypt_encrypt() is deprecated in /home4/sunshine/public_html/wp-content/plugins/gravityforms/common.php on line 5402

Solution - 

That indicates the reCAPTCHA field is using the old stoken integration method. To upgrade it to use the newer integration method you need to generate new reCAPTCHA api keys for your site and add them to the Forms > Settings page.

That should take care of it for you.

Saturday, August 24, 2019

Wordpress - Contact Form 7 notification open in popup - Bootstrap modal popup

How to add open Contact form 7 Notification / Messages in Modal popup

We can use the Bootstrap modal popup and Contact form 7 Doom Events to create the popup.

Paste the below code in the functions.php, it will work for you (please change the messages as per the requirements):

add_action('wp_footer', 'munesh_Footertext');
function munesh_Footertext() {
echo '<div class="modal fade in formids" id="myModal2" role="dialog" tabindex="-1">
    <div class="modal-dialog">


      <!-- Modal content-->
      <div class="modal-content no_pad text-center">
         <button type="button" class="close" data-dismiss="modal">&times;</button>
        <div class="modal-header heading">
          <h3 class="modal-title" id="MSTitle">Message Sent!</b></h3>
        </div>
        <div class="modal-body">
            <div class="thanku_outer define_float text-center" id="MSBody">Thank you for getting in touch!
            </div>
        </div>
        <div class="modal-footer">
        </div>
      </div>


    </div>
    </div>';
?>
     <script type="text/javascript">
         document.addEventListener( 'wpcf7invalid', function( event ) {
            jQuery('#MSTitle').html('Alert!');
            jQuery('#MSBody').html('One or more fields have an error. Please check and try again.');
             jQuery('#myModal2').modal('show'); }, false );
         </script>
<script type="text/javascript">
         document.addEventListener( 'wpcf7mailfailed', function( event ) {
            jQuery('#MSTitle').html('Alert!');
            jQuery('#MSBody').html('There was an error trying to send your message. Please try again later.');
             jQuery('#myModal2').modal('show'); }, false );
         </script>
<script type="text/javascript">
         document.addEventListener( 'wpcf7mailsent', function( event ) {
            jQuery('#MSTitle').html('Message Sent!');
            jQuery('#MSBody').html('Thank you for getting in touch. We will get back to you ASAP.');
             jQuery('#myModal2').modal('show'); }, false );
         </script>
<style>div.wpcf7-validation-errors, div.wpcf7-acceptance-missing, div.wpcf7-response-output {display:none!important;} .modal{top:25%!important;}</style>
       <?php
}

Link to contact form domain events  - https://contactform7.com/dom-events/


Monday, August 19, 2019

DataTables warning: table id=table1 - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3

Issue - DataTables warning: table id=table1 - Cannot reinitialise DataTable. For more information about this error, please see http://datatables.net/tn/3

Solution -
This error can often occur when trying to obtain a reference to the DataTable for working with the API. For example, you might have a function which will always try to create a DataTable instance by passing in options when created. Then you make a modification which calls this function on a table which has already been initialised and you get this error.
In such a case, you will want to use the $.fn.dataTable.isDataTable() static method. This can be used to check if a table is a DataTable or not already:
1
2
3
4
5
6
7
8
if ( $.fn.dataTable.isDataTable( '#table1' ) ) {
    table = $('#table1').DataTable();
}
else {
    table = $('#table1').DataTable( {
        paging: false
    } );
}

for more information please visit the page - https://datatables.net/manual/tech-notes/3

Monday, July 8, 2019

Issue SSL Certificate from the https://cheapsslsecurity.com using the CSR

Generate SSL Certificate: go to the recent order and click on the certificate and

  • Chose the domain validation option “Email Authentication” for this you have the access of one of the following emails:
  1. admin@yourdomain.com
  2. administrator@yourdomain.com
  3. webmaster@yourdomain.com
  4. postmaster@yourdomain.com
  5. hostmaster@yourdomain.com
  • Input CSR (Certificate Signing Request)
  • Select Your Server(optional) – left this as default or select “Microsoft Internet Information Server”
  • Select the Signature Algorithm – choose SHA2
  • Click on the continue – this will send a verification email of the selected email in the step Verify the verification – please verification by clicking the link received in the mail
  • Get SSL Certificate – You will receive a SSL certificate in the Mail

How to Install an SSL certificate on IIS

Install an SSL certificate on IIS
  • Press Win + R and type “inetmgr” in the appeared window to run the Internet Information Services (IIS) Manager.
  • On the IIS Manager home page, locate the “Server Certificates” icon and double-click it:

  • Locate the “Actions” panel on the right side and click “Complete Certificate Request”:
  • In the “Specify Certificate Authority Response” window, perform the actions below.
  1. In the “File name containing the certification authority’s response” field, browse the file system to select your .p7b (or .cer) certificate.
  2. In the “Friendly name” field, specify any name that will help you to identify the certificate among other files. It is best to submit the actual domain name of the certificate.
  3. In the “Select a certificate store for the new certificate” field, leave the default value “Personal”.
  • Click “OK” to import the certificate to the server storage.
  • Once the import is completed, in the “Server Certificates” window, you will see a new entry associated with the imported certificate:
  •  Assign the certificate to your website by expanding the “Sites” subsection in the “Connections” menu on the left and select the corresponding site. Then, in the “Actions” panel on the right side, locate the “Edit Site” menu and select the “Bindings” option:
  • On the right side of the “Site Bindings” window, click “Add”: 
  • In the “Add Site Binding” window, modify the fields as below:
  1. In the “Type” field, select “https”.
  2. In the “IP address” field, select your website’s IP address or “All Unassigned”.
  3. In the “Port” field, specify “443” (default).
  4. In the “SSL certificate” field, select the previously imported certificate, which can be identified by the friendly name:
    NOTE: The “Require Server Name Indication” box needs to be checked if there are multiple SSL certificates on the server.
  • Click “OK” in order for the new “https” entry to appear in the “Site Bindings” window:
  • That’s all - the certificate should now be installed and the website should be accessible via HTTPS.

How to Generate CSR from Microsoft IIS 7/ IIS 8/ IIS 10

Generate a CSR from Microsoft IIS

  • Open Internet Information Services (IIS) Manager - Click Start, Control Panel, Administrative Tools, and then select Internet Information Services (IIS) Manager.
  • Open Internet Information Services (IIS) Manager - In the left Connections menu, select the server name (host) where you want to generate the request.
  • Navigate to Server Certificates - In the center menu, click the Server Certificates icon under the Security section near the bottom
  • Select Create a New Certificate - In the right Actions menu, click Create Certificate Request.
  • Enter your CSR details - In the Distinguished Name Properties window, enter in the required CSR details and then click Next.
    Note: To avoid common mistakes when filling out your CSR details, reference 
  • Select a cryptographic service provider and bit length - In the Cryptographic Service Provider Properties window, select Microsoft RSA Channel Cryptographic Provider and Bit Length of 2048, then click Next.
    Note: Bit Length: 2048 is the current industry standard. You may choose a larger key size, but only if you have a requirement to do so, as longer key lengths increase latency and may reduce compatibility.
  • Save the CSR - Click Browse to specify the location where you want to save the CSR as a “.txt” file and click Finish.

How to generate CSR, purchase SSL from cheapest SSL and Install On IIS


Generate a CSR from Microsoft IIS

  • Open Internet Information Services (IIS) Manager - Click Start, Control Panel, Administrative Tools, and then select Internet Information Services (IIS) Manager.
  • Open Internet Information Services (IIS) Manager - In the left Connections menu, select the server name (host) where you want to generate the request.
  • Navigate to Server Certificates - In the center menu, click the Server Certificates icon under the Security section near the bottom
  • Select Create a New Certificate - In the right Actions menu, click Create Certificate Request.
  • Enter your CSR details - In the Distinguished Name Properties window, enter in the required CSR details and then click Next.
    Note: To avoid common mistakes when filling out your CSR details, reference 
  • Select a cryptographic service provider and bit length - In the Cryptographic Service Provider Properties window, select Microsoft RSA Channel Cryptographic Provider and Bit Length of 2048, then click Next.
    Note: Bit Length: 2048 is the current industry standard. You may choose a larger key size, but only if you have a requirement to do so, as longer key lengths increase latency and may reduce compatibility.
  • Save the CSR - Click Browse to specify the location where you want to save the CSR as a “.txt” file and click Finish.
Purchase SSL Certificate from cheapsslsecurity.com

Generate SSL Certificate: go to the recent order and click on the certificate and

  • Chose the domain validation option “Email Authentication” for this you have the access of one of the following emails:
  1. admin@yourdomain.com
  2. administrator@yourdomain.com
  3. webmaster@yourdomain.com
  4. postmaster@yourdomain.com
  5. hostmaster@yourdomain.com
  • Input CSR (Certificate Signing Request)
  • Select Your Server(optional) – left this as default or select “Microsoft Internet Information Server”
  • Select the Signature Algorithm – choose SHA2
  • Click on the continue – this will send a verification email of the selected email in the step Verify the verification – please verification by clicking the link received in the mail
  • Get SSL Certificate – You will receive a SSL certificate in the Mail

Install an SSL certificate on IIS
  • Press Win + R and type “inetmgr” in the appeared window to run the Internet Information Services (IIS) Manager.
  • On the IIS Manager home page, locate the “Server Certificates” icon and double-click it:

  • Locate the “Actions” panel on the right side and click “Complete Certificate Request”:
  • In the “Specify Certificate Authority Response” window, perform the actions below.
  1. In the “File name containing the certification authority’s response” field, browse the file system to select your .p7b (or .cer) certificate.
  2. In the “Friendly name” field, specify any name that will help you to identify the certificate among other files. It is best to submit the actual domain name of the certificate.
  3. In the “Select a certificate store for the new certificate” field, leave the default value “Personal”.
  • Click “OK” to import the certificate to the server storage.
  • Once the import is completed, in the “Server Certificates” window, you will see a new entry associated with the imported certificate:
  •  Assign the certificate to your website by expanding the “Sites” subsection in the “Connections” menu on the left and select the corresponding site. Then, in the “Actions” panel on the right side, locate the “Edit Site” menu and select the “Bindings” option:
  • On the right side of the “Site Bindings” window, click “Add”: 
  • In the “Add Site Binding” window, modify the fields as below:
  1. In the “Type” field, select “https”.
  2. In the “IP address” field, select your website’s IP address or “All Unassigned”.
  3. In the “Port” field, specify “443” (default).
  4. In the “SSL certificate” field, select the previously imported certificate, which can be identified by the friendly name:
    NOTE: The “Require Server Name Indication” box needs to be checked if there are multiple SSL certificates on the server.
  • Click “OK” in order for the new “https” entry to appear in the “Site Bindings” window:
  • That’s all - the certificate should now be installed and the website should be accessible via HTTPS.





Friday, July 5, 2019

How to add ads.txt to blogger.com?

Set up an ads.txt file

If your blog is monetized with third-party providers or you’ve manually integrated AdSense in your blog, you will need to manually set up the content of the ads.txt file.
  1. Sign in to Blogger.
  2. In the top left, click the Down arrow  .
  3. Click the blog you want to set up an ads.txt file on.
  4. On the left, click Settings.
  5. Under "Settings," click Search preferences.
  6. Under "Monetization," find "Custom ads.txt" and click Edit.
  7. Click Yes.
  8. Copy the settings from your third-party monetization provider and paste them in the text box.
  9. Click Save settings.
  10. Optional: To check the content of your ads.txt file, go to http:///ads.txt.
Note: If your blog is not monetized, or it’s only configured to use AdSense using the Blogger-AdSense integration, then you do not need to manually set up ads.txt. Blogger will do this for you. Read more about ads.txt for AdSense.

Sql-Server the Select permission was denied on the object 'types', Error 229

Please check that you didn't check the following  DB role:
1. db_denydatareader
2. db_denydatawriter

Please uncheck both of them, this will solve your problem.
















Steps to uncheck the roles:
  1. Open SQL Management Studio
  2. Expand your database
  3. Expand the "Security" Folder
  4. Expand "Users"
  5. Right click the user (the one that's trying to perform the query)
  6. Make sure you uncheck