Ir para conteúdo
  • ×   Você colou conteúdo com formatação.   Remover formatação

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

  • Conteúdo Similar

    • Por Darlysson
      Olá, Pessoal! Por favor, movam o tópico se estiver em uma área errada.
      Sou iniciante e preciso muito da ajuda de vocês!
      Eu tenho a tabela (usuarios) no MySQL, dentro dessa tabela existe uma coluna chamada (valor). 
      Todos os usuários registrados ganham 50 nessa coluna (valor) da tabela de usuários.
      o que eu preciso?
      Preciso que todo dia a coluna (Valor) da tabela (usuarios) tenha 50 para todos. 
      Não acrescentar, nem diminuir, mas atualizar essa coluna todo dia para 50 para todos os usuários.
      Pode ser por cron jobs também.
       
      Me ajudem, por favor!
    • Por wellingtonmelo
      Olá pessoal, beleza?
      Gosto muito de trabalhar com o wordpress, apesar de não manjar muito de php.
      Eu uso um código em alguns de meus projetos, ele cria um campo tipo texto na página dos posts, dai é possível colocar qualquer conteúdo em cada post, ou seja, é individual para cada post. Segue imagem com exemplo:

      Minha dúvida creio que seja bem simples, ele está configurado para funcionar no single.php, mas preciso que ele funciona na página individual dos produtos (woocommerce).
      Creio que alguém que programe em php, saiba o local onde mudar, para mudar o single.php para a página do produto.
      Segue código que vai no functions.php:
      <?php /*-----------------------------------------------------------------------------------*/ // Inicio Area Inserir campo, single.php /*-----------------------------------------------------------------------------------*/ $sp_boxes = array ( 'Informações do Jogo' => array ( array( 'howto1', 'Descrição curta:', 'textarea' ), array( 'howto2', 'Classificação:', 'textarea' ), ), ); // Do not edit past this point. // Use the admin_menu action to define the custom boxes add_action( 'admin_menu', 'sp_add_custom_box' ); // Use the save_post action to do something with the data entered // Save the custom fields add_action( 'save_post', 'sp_save_postdata', 1, 2 ); // Adds a custom section to the "advanced" Post and Page edit screens function sp_add_custom_box() { global $sp_boxes; if ( function_exists( 'add_meta_box' ) ) { foreach ( array_keys( $sp_boxes ) as $box_name ) { add_meta_box( $box_name, __( $box_name, 'sp' ), 'sp_post_custom_box', 'post', 'normal', 'high' ); } } } function sp_post_custom_box ( $obj, $box ) { global $sp_boxes; static $sp_nonce_flag = false; // Run once if ( ! $sp_nonce_flag ) { echo_sp_nonce(); $sp_nonce_flag = true; } // Genrate box contents foreach ( $sp_boxes[$box['id']] as $sp_box ) { echo field_html( $sp_box ); } } function field_html ( $args ) { switch ( $args[2] ) { case 'textarea': return text_area( $args ); case 'checkbox': // To Do case 'radio': // To Do case 'text': default: return text_field( $args ); } } function text_field ( $args ) { global $post; // adjust data $args[2] = get_post_meta($post->ID, $args[0], true); $args[1] = __($args[1], 'sp' ); $label_format = '<label for="%1$s">%2$s</label><br />' . '<input style="width: 95%%;" type="text" name="%1$s" value="%3$s" /><br /><br />'; return vsprintf( $label_format, $args ); } function text_area ( $args ) { global $post; // adjust data $args[2] = get_post_meta($post->ID, $args[0], true); $args[1] = __($args[1], 'sp' ); $label_format = '<label for="%1$s">%2$s</label><br />' . '<textarea style="width: 95%%;" name="%1$s">%3$s</textarea><br /><br />'; return vsprintf( $label_format, $args ); } /* When the post is saved, saves our custom data */ function sp_save_postdata($post_id, $post) { global $sp_boxes; // verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times if ( ! wp_verify_nonce( $_POST['sp_nonce_name'], plugin_basename(__FILE__) ) ) { return $post->ID; } // Is the user allowed to edit the post or page? if ( 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post->ID )) return $post->ID; } else { if ( ! current_user_can( 'edit_post', $post->ID )) return $post->ID; } // OK, we're authenticated: we need to find and save the data // We'll put it into an array to make it easier to loop though. // The data is already in $sp_boxes, but we need to flatten it out. foreach ( $sp_boxes as $sp_box ) { foreach ( $sp_box as $sp_fields ) { $my_data[$sp_fields[0]] = $_POST[$sp_fields[0]]; } } // Add values of $my_data as custom fields // Let's cycle through the $my_data array! foreach ($my_data as $key => $value) { if ( 'revision' == $post->post_type ) { // don't store custom data twice return; } // if $value is an array, make it a CSV (unlikely) $value = implode(',', (array)$value); if ( get_post_meta($post->ID, $key, FALSE) ) { // Custom field has a value. update_post_meta($post->ID, $key, $value); } else { // Custom field does not have a value. add_post_meta($post->ID, $key, $value); } if (!$value) { // delete blanks delete_post_meta($post->ID, $key); } } } function echo_sp_nonce () { // Use nonce for verification ... ONLY USE ONCE! echo sprintf( '<input type="hidden" name="%1$s" id="%1$s" value="%2$s" />', 'sp_nonce_name', wp_create_nonce( plugin_basename(__FILE__) ) ); } // A simple function to get data stored in a custom field if ( !function_exists('get_custom_field') ) { function get_custom_field($field) { global $post; $custom_field = get_post_meta($post->ID, $field, true); echo $custom_field; } } /*-----------------------------------------------------------------------------------*/ // Fim Area Inserir campo, single.php /*-----------------------------------------------------------------------------------*/ Segue código que imprime os dois campos:
      <div class="local-onde-aparece-o-campo"> <?php $values = get_post_custom_values("howto1"); echo $values[0]; ?> <?php $values = get_post_custom_values("howto2"); echo $values[0]; ?> </div> Peço desculpa pelo longo código, é que realmente ainda não entendo bem de php.
      Grato por toda ajuda. Obrigado!
    • Por Spingamer
      Código por: Don Benatti. (Aqui do Forum mesmo) (Link fo post)
      Ele me ajudou aqui no forum, mas infelizmente não funfou :/ creio que precisa de alguma pequena correção
      Se você achar o erro posta corrigido pra mim? Obrigaduuu
      <?php $html = '<!doctype html> <html> <head> <link rel="shortcut icon" href="http://www.wix.com/favicon.ico" type="image/x-icon"/> <link rel="apple-touch-icon" href="http://www.wix.com/favicon.ico" type="image/x-icon"/> </head> <body></body> </html>'; $dom = new DOMDocument(); // Carrega o conteúdo HTML $dom->loadHTML($html); $dom->preserveWhiteSpace = false; $xpath = new DOMXPath($dom); $links = $xpath->query("//link[@type='image/x-icon']"); if ($links->length) { foreach ($links as $link) { // Aqui removemos $link->parentNode->removeChild($link); } } O que poderia ser?
       
×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.