php – Source link plugin – show just anchor / link

I implemented a small source link plugin on my WordPress website via the following codes.

Single.php:

                        <?php
global $post, $pages, $page;

$total = count( $pages );
// Link źródłowy
if ( $total < 2 || $page === $total ) :
    
    if ( $url = get_post_meta( $post->ID, '_source_link', true ) ) :
        $label = get_post_meta( $post->ID, '_source_link_label', true );
        $label = $label ? $label : $url;
    ?>
        <div class="source-link">
            <b>Źródło:</b> <a href="<?php echo esc_url( $url ); ?>" rel="nofollow" target="_blank"><?php  
              echo esc_html( $label ); ?></a>
        </div>
    <?php endif; 
endif; 
?>

Functions.php:

add_action( 'add_meta_boxes', 'wpse_source_link' );


add_action( 'save_post', 'wpse_source_link_save' );


function wpse_source_link() {

    add_meta_box(
        'source_link',
        __( 'Link źródłowy', 'myplugin_textdomain' ), 
        'wpse_source_meta_box',
        'post',
        'side'
    );
}


function wpse_source_meta_box( $post ) {

 
  wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );

  
  echo '<label for="source-link">Link</label> ';
  echo '<input type="text" id="source-link"" name="source_link" value="'.
    get_post_meta( $post->ID, '_source_link', true ) .'" size="25" />';

  echo '<label for="source-link-label">Nazwa strony</label> ';
  echo '<input type="text" id="source-link-label"" name="source_link_label" value="'.
    get_post_meta( $post->ID, '_source_link_label', true ) .'" size="25" />';
}


function wpse_source_link_save( $post_id ) {

  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 
      return;

  if ( ! wp_verify_nonce( $_POST('myplugin_noncename'), plugin_basename( __FILE__ ) ) )
      return;


  if ( current_user_can( 'edit_post', $post_id ) ) {

      update_post_meta( $post_id, '_source_link', sanitize_text_field( $_POST('source_link') ) );
      update_post_meta( $post_id, '_source_link_label', sanitize_text_field( $_POST('source_link_label') ) );

   }
}

As you can see there are two fields:
Link źródłowy (Source link) and Nazwa strony (website name – anchor). However, at this moment this plugin only works, when both fields have some text inside. Is there any way to make it work also with just anchor/link? I mean, if two fields are completed it should show anchor with link, but if just anchor has some text in it, then it should show only anchor. Same goes for link.

Does anyone know how to make it work like that? To be honest I’m a newbie and I have no idea.

php – Source link plugin – show just anchor/link

I implemented a small source link plugin on my WordPress website via the following codes:

add_action( 'add_meta_boxes', 'wpse_source_link' );


add_action( 'save_post', 'wpse_source_link_save' );


function wpse_source_link() {

    add_meta_box(
        'source_link',
        __( 'Link źródłowy', 'myplugin_textdomain' ), 
        'wpse_source_meta_box',
        'post',
        'side'
    );
}


function wpse_source_meta_box( $post ) {

 
  wp_nonce_field( plugin_basename( __FILE__ ), 'myplugin_noncename' );

  
  echo '<label for="source-link">Link</label> ';
  echo '<input type="text" id="source-link"" name="source_link" value="'.
    get_post_meta( $post->ID, '_source_link', true ) .'" size="25" />';

  echo '<label for="source-link-label">Nazwa strony</label> ';
  echo '<input type="text" id="source-link-label"" name="source_link_label" value="'.
    get_post_meta( $post->ID, '_source_link_label', true ) .'" size="25" />';
}


function wpse_source_link_save( $post_id ) {

  if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 
      return;

  if ( ! wp_verify_nonce( $_POST('myplugin_noncename'), plugin_basename( __FILE__ ) ) )
      return;


  if ( current_user_can( 'edit_post', $post_id ) ) {

      update_post_meta( $post_id, '_source_link', sanitize_text_field( $_POST('source_link') ) );
      update_post_meta( $post_id, '_source_link_label', sanitize_text_field( $_POST('source_link_label') ) );

   }
}
                        <?php
global $post, $pages, $page;

$total = count( $pages );
// Link źródłowy
if ( $total < 2 || $page === $total ) :
    
    if ( $url = get_post_meta( $post->ID, '_source_link', true ) ) :
        $label = get_post_meta( $post->ID, '_source_link_label', true );
        $label = $label ? $label : $url;
    ?>
        <div class="source-link">
            <b>Źródło:</b> <a href="<?php echo esc_url( $url ); ?>" rel="nofollow" target="_blank"><?php  
              echo esc_html( $label ); ?></a>
        </div>
    <?php endif; 
endif; 
?>

As you can see there are two fields:
Link źródłowy (Source link) and Nazwa strony (website name – anchor). However, at this moment this plugin only works, when both fields have some text inside. Is there any way to make it work also with just anchor/link? I mean, if two fields are completed it should show anchor with link, but if just anchor has some text in it, then it should show only anchor. Same goes for link.

php – CORS IS PRESENT IN THE REQUESTED SOURCE

I have been trying to setup a gambling script, with node.js but when i start the nodejs de website gives a error saying that has been blocked by CORS policy,

I have tryed :

  • Using cors packet, and defining cors response;

But it is not working, i would appreciate if someone knows the answer.

web development – Making completely open source website with abstracted user data

I am planning on making a non-profit opensource website built with Django or Flask with abstracted data since there will be authentication process and profile data, which can’t be made public.

I can’t use Github Pages for it since I can’t make dynamic website with it, performance wouldn’t be that good and custom domain name is not possible.

If anybody knows how to develop such website without actually abstracting the code would be of great help.

Compilation from source: LESS file is empty: order email sent without css and an warning

Getting this error while sending order emails.Compilation from source: LESS file is empty: order email sent without css and an warning

What are the differences between magento cloud extension and open source extension?

I am searching about cloud extension and open-source extension in Magento. I didn’t find any differences between them.

Please explain the differences and similarities Magento cloud extension and open-source extension.

Custom migrate source plugin, extends FieldableEntity class, has migrate status of [error] No migrations found. Why?

I’m writing a migrate source plugin for migrating D7 entityform (entityform module) submissions. If anyone has done this or knows an existing plugin, please let me know.

I am trying to extend the FieldableEntity base class from Drupalmigrate_drupalPluginmigratesourced7FieldableEntity; because I want to use its getFields() and getFieldValues() methods when I override prepareRow() to include custom fields from my D7 entityform.

My problem is that when my source plugin extends FieldableEntity, drush reports (error) No migrations found. for my migration. Importantly, however, if my source plugin instead uses the SqlBase class from DrupalmigratePluginmigratesourceSqlBase, then drush can import all of my entityforms from D7 into D9 contact forms no problem. So it would seem that I am missing something when I try to implement FieldableEntity preventing it from retrieving data for the migration.

Here is my plugin, which shows up fine in drush ms:

<?php

namespace Drupalmymodule_migratePluginmigratesource;

use DrupalmigrateRow;
use Drupalmigrate_drupalPluginmigratesourced7FieldableEntity;

/**
 * The 'mymodule_migrate_entityform' source plugin.
 *
 * @MigrateSource(
 *   id = "mymodule_migrate_entityform",
 *   source_module = "mymodule_migrate"
 * )
 */
class Entityform extends FieldableEntity {

  /**
   * {@inheritdoc}
   */
  public function query() {
    $query = $this->select('entityform', 'e')
      ->fields('e', (
        'entityform_id',
        'type',
        'created',
        'changed',
        'uid'
      ));
    return $query;
  }

  /**
   * {@inheritdoc}
   */
  public function fields() {
    return array(
      'entityform_id' => $this->t('The ID of the entityform submission.'),
      'type' => $this->t('The entityform type.'),
      'created' => $this->t('The time that the entityform was submitted.'),
      'changed' => $this->t('Last updated time.'),
      'uid' => $this->t('The {users}.uid who submitted the entityform. If set to 0, this entityform was submitted by an anonymous user.'),
    );
  }

  /**
   * {@inheritdoc}
   */
  public function getIds() {
    $ids('entityform_id')('type') = 'integer';
    $ids('entityform_id')('alias') = 'e';
    return $ids;
  }

  /**
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    $entityform_id = $row->getSourceProperty('entityform_id');
    // Get Field API field values.
    foreach ($this->getFields('entityform', 'BUNDLE_MACHINE_NAME') as $field_name => $field) {
      $row->setSourceProperty($field_name, $this->getFieldValues('entityform', $field_name, $entityform_id));
    }
    return parent::prepareRow($row);
  }

}

I use this yml migration definition. My migrate destination is D8/D9 contact_message entity.

id: mymodule_contact_message
label: D8 Contact message migration from D7 entityform submission
source:
  plugin: mymodule_migrate_entityform
process:
  id: entityform_id
  langcode:
    plugin: default_value
    source: language
    default_value: "und"
  created: created
  changed: changed
destination:
  plugin: entity:contact_message
  default_bundle: MY_DESTINATION_BUNDLE

As stated above, all of this works great when I use SqlBase in my plugin. But with FieldableEntity drush comes back with (error) No migrations found.

pulseaudio howto listen to a source

So simple no one answers howto

I have a source (no app running). I can see it moving-levels in pavucontrol (inputs)
I have a sink that does work (outputs) (hdmi)
I want to listen to the source. (no complications, no apps, just listen)
how?

how can I analyze my website's source code?

Hi! I think there is a destructive code in my website's source code. how can I analyze it? Is there any tools?

open source alternative of some online designer like "cloudcraft"

https://app.cloudcraft.co/ is a nice place for you to design cloud architecture.

I would like to know is there any open-source project that could let you drag some objects to the grid and connect them and visualize them.