- Immediately-Invoked-Function-Expressions
(function () { // code })();
** What does it do? -- It declares a function which in turn calls itself immediately (invokes). -- The function creates a new "scope" and creates "privacy" within itself.
| <?php | |
| /** | |
| * @package ninja_image_upload | |
| * @version 1.0 | |
| */ | |
| /* | |
| Plugin Name: Ninja Image Upload | |
| Plugin URI: http://authlab.io/ | |
| Description: This plugin allow users to upload image via a form can be created by shortcode | |
| Version: 1.0 |
| /** | |
| * Save a file submitted from a POST request and create an attachment post for it. | |
| * | |
| * @since 2.5.0 | |
| * | |
| * @param string $file_id Index of the `$_FILES` array that the file was sent. Required. | |
| * @param int $post_id The post ID of a post to attach the media item to. Required, but can | |
| * be set to 0, creating a media item that has no relationship to a post. | |
| * @param array $post_data Overwrite some of the attachment. Optional. | |
| * @param array $overrides Override the wp_handle_upload() behavior. Optional. |
(function () { // code })();
** What does it do? -- It declares a function which in turn calls itself immediately (invokes). -- The function creates a new "scope" and creates "privacy" within itself.
| // work around to fix navtabs issue https://github.com/twbs/bootstrap/issues/23667 | |
| $('a[data-toggle="tab"]').click(function(){ | |
| // todo remove snippet on bootstrap v4 | |
| $('a[data-toggle="tab"]').click(function() { | |
| $($(this).attr('href')).show().addClass('show active').siblings().hide(); | |
| }) | |
| }); |
| .text-overlay-center{ | |
| position:absolute; | |
| top:50%; | |
| left:50%; | |
| text-align:center; | |
| transform: translateX(-50%) translateY(-50%); | |
| } | |
| .text-overlay-left{ | |
| position: absolute; | |
| top: 45%; |
| /** Pop Post Modal **/ | |
| // Quick view ajax function on products page | |
| $('body').on('click', '.modal-link', function (e) { | |
| var post_id = $(this).data('id'); | |
| // prevent link from being followed | |
| e.preventDefault(); |
| Various functions for retrieving, formatting, and displaying native Wordpress comments. | |
| 1. Use the [ comment_form($args=array($fields=array(),...... ] function to display a default comment form inside the loop. | |
| * To customize the display of a comment form you can use the function's (args). | |
| ** Default Args: | |
| $defaults = array( | |
| 'fields' => $fields, | |
| 'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" maxlength="65525" aria-required="true" required="required"></textarea></p>', | |
| /** This filter is documented in wp-includes/link-template.php */ |
| $('img.avatar').error(function(){ | |
| $(this).addClass('is-broken'); | |
| }); |
| // Hide the image on error | |
| $("img").error(function(){ | |
| $(this).hide(); | |
| }); | |
| // Change the missing image to a default image | |
| $('img').error(function(){ | |
| $(this).attr('src', 'no-image.jpg'); | |
| }); |