Posts by brasofilo • 6,560 points
159 posts
-
2
votes2
answers3116
viewsA: How do I keep a website page at the same point it was before updating?
Can be solved with a anchor just before the <form>: <a name="form-anchor"></a> <form ETC... And make the action of the form go to that anchor: action="<?php echo…
-
5
votes1
answer1497
viewsA: Dynamically manipulating the DOM with jQuery
Within the <ul>, the <li> are differentiated by the class ms-selected, and the function hasClass() will determine this. Here, I’m making a loop with: $('.ms-selection ul.ms-list…
-
2
votes2
answers65
viewsA: Diversify Wordpress posts by Categories
You can make secondary loops using WP_Query <?php while ( have_posts() ) : the_post(); ?> <?php /* LOOP PRIMARIO */ ?> <?php endwhile; ?> <?php # Vide…
-
6
votes2
answers281
viewsA: Leave web page text manageable
Do with Wordpress can be a bit like putting a tractor where needed a VW, but usually this kind of thing tends to escalate: today is a small text, tomorrow are five texts and some images, and so on.…
-
5
votes6
answers10935
views -
61
votes4
answers49363
viewsQ: What is console.log?
I see this in some Javascript files: console.log(algumaCoisa); console.log("alguma coisa"); What it’s for and how it works? I’m trying to make a log() customized for a Userscript (see How can I log…
javascriptasked brasofilo 6,560 -
5
votes2
answers4525
viewsA: Create page (page) only in Wordpress PHP code
I’ve written plugins that do similar things but using a template inside the plugin’s own folder and intercepting with template_redirect. I believed I had something similar already written but I…
-
4
votes3
answers415
viewsA: Use PHP variable in JS file
I use the following technique, in the PHP file create a global object: <?php ?> <script> var lang = { day: 'Jour' }; </script> <?php ?> And use in JS:…
-
2
votes2
answers911
viewsA: Refresh-free browsing
Your confusion is $(".tc").click(function(){ AQUI });. Change to: $(".tc").click(function(){ $("#conteudo").fadeOut('slow',function(){ loading(1); var link = $(this).attr("data-url"); var tipo =…
-
6
votes1
answer501
viewsA: Run jQuery function in dynamically generated table after an AJAX
It is a matter of scope, the this down in the success is something else: $('#tabelaMaterial').on('click', '.icon-remove', function (event) { var $this = $(this); $.ajax({ url:…
-
2
votes3
answers460
viewsA: Pop-up opening before being clicked by button
You have two problems with your code: two equal ids and this cannot: button#popup and div#popup you are asking to show the div#abc but all the content is inserted inside it; I believe it wants to…
javascriptanswered brasofilo 6,560 -
3
votes2
answers8021
viewsA: Translate Woocommerce input texts
As the plugin documentation on Translating Woocommerce (Localization), these are the steps: define the language of the site on wp-config.php define('WPLANG', 'pt_BR'); the following notification…
-
3
votes1
answer125
viewsA: Error fetching video by location in Youtube Api V3
Add an action ray, otherwise think that he only looks for the exact coordinate. Here, his same query with locationRadius of 5km:…
-
1
votes2
answers495
viewsA: How to use Wordpress Media Upload on multiple buttons?
Using the event.currentTarget you can tell which button was clicked and apply the attachment.url to the previous element: $('.definir_imagem_button').click(function(e) { e.preventDefault(); var…
-
1
votes3
answers5268
viewsA: Events onmouseover and onmouseout slow to exchange images
Perhaps it is the case to make a preview of the secondary image before showing the primary. The images below are 900 and 700 KB, larger images can be found here. function preloadImagem( url ) { var…
-
5
votes3
answers44043
viewsA: How to put icon inside input using Font Awesome?
This answer does not solve the problem presented. It is similar because the icon is inside the input but it does not serve as a button to trigger the search. I found the solution in Use Font Awesome…
-
5
votes1
answer1335
viewsQ: Run custom functions in the browser console
It’s a little tiring having to keep writing console.log() all the time. I know that in my code I can define the function log that does just that. But outside the app environment, I would like to…
-
2
votes1
answer1335
viewsA: Run custom functions in the browser console
What Nice Alert does is basically: var w = window; if (!w.alert.is_nice) { w.alert = function alert(msg) {/*etc*} } Here is a solution like browser extension and Userscript. An extension has more…
-
1
votes1
answer78
viewsA: Creating a Wordpress Ad Insertion Area
You’re looking for Custom Fields (custom Fields) and Meta Boxes. When we create a meta box, we use custom Fields to store the information. If our field starts with _ will not appear in the custom…
-
5
votes4
answers173
viewsQ: Javascript PHP sprintf equivalent
Instead of doing: var html = '<a href="' + data.href + '" title="' + data.title + '">' + data.desc + '</a>'; I’m making: var html = '<a href="{href}"…
-
3
votes1
answer784
viewsQ: Run jQuery on console on a page that doesn’t have jQuery
Often, jQuery is very useful to take some statistics off the page and others cositas, just make a $('.elemento').each(callback) and you can already start to know what is happening on the page. The…
-
4
votes1
answer784
viewsA: Run jQuery on console on a page that doesn’t have jQuery
There is a way yes, as we can see in Soen’s reply: Include jQuery in the Javascript Console. Just do Paste code on the console and jQuery will be loaded. We can then use it freely on the console.…
-
2
votes2
answers936
viewsA: Adding values of selected input’s within another input
It is necessary to listen to the .change() of radio inputs and change the .val() of the text input according to this change. I added the class my-radio for these buttons and my-result for the text…
-
3
votes1
answer836
viewsA: Registration of users in Wordpress with custom form
Your problem is in "redirects to the following page in PHP". Surely you made an independent page that is outside the scope of Wordpress and does not recognize its functions. Here is an example of…
-
2
votes1
answer1087
viewsA: Photos in different Ivs using instafeed.js
That’s exactly what the Lucas spoke, use the option template of instafeed and also the function getMultipleTags() posted in the Issue linked #12. <style> .insta-pic { background-color: #fcc;…
-
9
votes1
answer619
viewsQ: Calculate the number of elements with CSS
I’m making a numbered list of regressive counters using the counter-reset. Currently I put the number of items in the list manually: .faq { counter-reset:my-counter 2; } .faq dt { counter-increment:…
-
1
votes1
answer384
viewsA: Doubt when picking up repeated checkbox group
You have to input as a multidimensional array: name="dias[0][]": <form action="test.php" method="post"> <input type="checkbox" name="dias[0][]" value="Segunda"> Seg <input…
-
11
votes2
answers183
viewsA: How to insert a header to each N records?
You need the module operator (%), which is the rest of the $a for $b. Before the loop we open a counter with 0 and increase $count++. And when ( $count % 4 ) === 0 print the header. $count = 0;…
-
1
votes2
answers146
viewsA: How to decrease the response time of an unsuccessful connection when using Ksoap2?
I found the solution, which by the way is very simple. It was lack to look a little more or use the right terms. Just pass as argument a value in milliseconds on the line HttpTransportSE…
-
4
votes2
answers84
viewsA: How to insert a REQUIRE in this function?
Complementing Bruno Augusto’s response. It is not recommended to use global, but it is also not the end of the world (the WP itself is full of them), so in the plugin main file: $my_plugin_url =…
-
4
votes2
answers1218
viewsA: Integration with Wordpress authentication
It is possible to point out the tables wp_user and wp_usermeta to others in the same DB using the following constants in wp-config.php: define( 'CUSTOM_USER_TABLE', $table_prefix.'my_users' );…
-
1
votes1
answer204
viewsA: How to insert Wordpress icons in the administrative area menu?
Just use one of the classes of dashicons.css, as dashicons-chart-pie or dashicons-welcome-learn-more: add_action('admin_menu', function() { # $page_title, $menu_title, $capability, $menu_slug,…
-
4
votes3
answers3185
viewsA: How to create random audio playlist?
What I find legal in these cases of Random playlist is to remove the already played elements from the array, so it does not risk repeating. And when you empty the array, you populate it back with…
-
3
votes1
answer292
viewsA: How to make a conditional loop in Wordpress depending on the category?
As a general rule, stay away from query_posts, this is the main query and when modifying it is almost certain to create more problems than solutions, see When should you use Wp_query vs…
-
1
votes1
answer246
viewsA: In a Wordpress gallery, use the Alt attribute of the images as html comment
1) Missed you show the filter calling your function. But surely it is: add_filter( 'post_gallery', '__my_gallery_shortcode', 10, 2 ); function __my_gallery_shortcode( $output, $attr ) {} Notice that…
-
3
votes1
answer54
viewsQ: Why doesn’t inArray detect capital letters?
I don’t understand why when I look for PALAVRA the inArray() jQuery does not find it. But if I look for palavra is positive when the array is PALAVRA. The first test I expected to be positive does…
-
8
votes12
answers5446
viewsA: How to remove accent in upload with php?
I use the plugin code Germanix, from one of the moderators of Wordpress Developers and who knows much character encoding and Internationalization and Localization. First, he makes a…
-
36
votes8
answers309745
viewsQ: Reduce image size and maintain CSS aspect ratio
If I have a horizontal image (320x205), <div class="container"> <img src="imagem.jpg" width="320" height="205" /> </div> and I put the CSS rule .container img { max-width: 200px;…
-
52
votes8
answers309745
viewsA: Reduce image size and maintain CSS aspect ratio
Lack of value auto to the width and height. So the scale is made according to width or height (what reaches first) and the ratio is made automatically. .container img { max-width:200px;…
-
9
votes2
answers4983
viewsA: How do I let the bottom of the page degrade with Javascript?
The great onetrickpony has an example using the HTML element canvas. According to the documentation, the element is supported by Firefox 1.5+, IE 9+, Chrome and Opera 9. For versions smaller than IE…
-
1
votes2
answers130
viewsA: Bxslider plugin does not show thumbnail
The problem is that pagerCustom not for use with dynamic carousels: [...] Not for use with Dynamic Carousels. And also that the Pager does not match the number of slides, but the number of pages.…
-
2
votes2
answers470
viewsA: How to run PHP Data Import code for Wordpress site?
You can use the register_activation_hook, that runs only on plugin activation: <?php /** * Plugin Name: (SOPT) Teste Activation Hook */ register_activation_hook( __FILE__, 'activate_sopt_32701'…
-
1
votes1
answer262
viewsA: How to use Magicline in Single Page navigation?
You have to calculate if the scroll is going through one of <div class="boxes" id="ID">, take that ID and trigger the state of mouseover of <a href="#ID"> correspondent. The plugin…
-
1
votes1
answer128
viewsA: Force user to mark custom taxonomy in Wordpress
This is a classic in WPSE: Force Category Choice before Creating new post? It is necessary to adapt the post_type, add custom taxonomy in wp_dropdown_categories and use the function…
-
1
votes3
answers82
viewsA: Transparency of a SWF with wmode=Transparent does not work in Firefox
If you use the Swfobject, You’ll probably get rid of that problem. It is the recommended way to insert Flash objects into HTML, and is required if you want SWF and Javascript to be able to pass…
-
4
votes3
answers6609
viewsA: Print without confirmation window in PHP, Javascript or Ajax
In Firefox it is a matter of setting up print.always_print_silent: place in the URL bar: about:config look for this config and mark as true if it does not exist, right-click and ask for "New" ->…
-
3
votes1
answer850
viewsA: Different ways to stream a video
It depends on factors such as privacy, cost of bandwidth (which relates to the amount of visitors) and formatting of videos suitable for web. If it is your server, in theory, the files are under…
-
5
votes1
answer198
viewsQ: Global Differences in Userscripts in Chrome and Firefox
I started programming Userscripts in Chrome and almost all snippets of code I find work, but when going pro Firefox gives problem. In Chrome I use the Tampermonkey and in Firefox the Scriptish…
-
3
votes2
answers1324
viewsA: Compare files with PHP
I found this class here [mirror] that implements a Diff in PHP. I tested with a file .json simple, making a copy and deleting an object, the result is: And this is PHP test file:…
-
4
votes1
answer123
viewsA: Handling events in elements added later
When the element does not exist in the DOM, has to do the delegation of the event on document, or a closer element encompassing .foo's: $(document).on( 'click', '.foo', function(e){ alert('bar');…