Skip to main content
deleted 90 characters in body
Source Link
Tom
  • 1
  • 1

Thanks Paul, you led me to the solution.

What I did

In class-mypluging-admin.php, I added this:

/** * Additional arguments for this plugin. * * @since 1.0.0 * @access private * @var array $args The current arguments of this plugin. */ private $args; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. * @param array $args The additional arguments of this plugin. */ public function __construct( $plugin_name, $version, $args = null ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->args = $args; } 

Then for the functions in class-mypluging-admin.php

function some_function( $views ) { if( !isset($this->args['post_type'])) throw new Exception('Argument missing.');; $post_type = $this->args['post_type']; ... } 

In class-mypluging.php, I do this:

foreach($post_types as $post_type) { $args = array( 'post_type' => $post_type, ); $plugin_admin = new MyPlugin_Admin( $this->get_plugin_name(), $this->get_version(), $args ); $this->loader->add_action("views_edit-{$post_type}", $plugin_admin, 'some_function'); } 

And it works! Is that the correct way to do this?

Thanks Paul, you led me to the solution.

What I did

In class-mypluging-admin.php, I added this:

/** * Additional arguments for this plugin. * * @since 1.0.0 * @access private * @var array $args The current arguments of this plugin. */ private $args; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. * @param array $args The additional arguments of this plugin. */ public function __construct( $plugin_name, $version, $args = null ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->args = $args; } 

Then for the functions in class-mypluging-admin.php

function some_function( $views ) { if( !isset($this->args['post_type'])) throw new Exception('Argument missing.');; $post_type = $this->args['post_type']; ... } 

In class-mypluging.php, I do this:

foreach($post_types as $post_type) { $args = array( 'post_type' => $post_type, ); $plugin_admin = new MyPlugin_Admin( $this->get_plugin_name(), $this->get_version(), $args ); $this->loader->add_action("views_edit-{$post_type}", $plugin_admin, 'some_function'); } 

And it works! Is that the correct way to do this?

Thanks Paul, you led me to the solution.

What I did

In class-mypluging-admin.php, I added this:

/** * Additional arguments for this plugin. * * @since 1.0.0 * @access private * @var array $args The current arguments of this plugin. */ private $args; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. * @param array $args The additional arguments of this plugin. */ public function __construct( $plugin_name, $version, $args = null ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->args = $args; } 

Then for the functions in class-mypluging-admin.php

function some_function( $views ) { $post_type = $this->args['post_type']; ... } 

In class-mypluging.php, I do this:

foreach($post_types as $post_type) { $args = array( 'post_type' => $post_type, ); $plugin_admin = new MyPlugin_Admin( $this->get_plugin_name(), $this->get_version(), $args ); $this->loader->add_action("views_edit-{$post_type}", $plugin_admin, 'some_function'); } 

And it works! Is that the correct way to do this?

added 107 characters in body
Source Link
Tom
  • 1
  • 1

Thanks Paul, you led me to the solution.

What I did

In class-mypluging-admin.php, I added this:

/** * Additional arguments for this plugin. * * @since 1.0.0 * @access private * @var array $args The current arguments of this plugin. */ private $args; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. * @param array $args The additional arguments of this plugin. */ public function __construct( $plugin_name, $version, $args = null ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->args = $args; } 

Then for the functions in class-mypluging-admin.php

function some_function( $views ) { if( !isset($this->args['post_type'])) throw new Exception('Argument missing.');; $post_type = $this->args['post_type']; ... } 

In class-mypluging.php, I do this:

foreach($values$post_types as $post_type) { $args = array( 'post_type' => $post_type, ); $plugin_admin = new MyPlugin_Admin( $this->get_plugin_name(), $this->get_version(), $args ); $this->loader->add_action("views_edit-{$post_type}", $plugin_admin, 'some_function'); } 

And it works! Is that the correct way to do this?

Thanks Paul, you led me to the solution.

What I did

In class-mypluging-admin.php, I added this:

/** * Additional arguments for this plugin. * * @since 1.0.0 * @access private * @var array $args The current arguments of this plugin. */ private $args; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. * @param array $args The additional arguments of this plugin. */ public function __construct( $plugin_name, $version, $args = null ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->args = $args; } 

Then for the functions in class-mypluging-admin.php

function some_function( $views ) { if( !isset($this->args['post_type'])) throw new Exception('Argument missing.');; $post_type = $this->args['post_type']; ... } 

In class-mypluging.php, I do this:

foreach($values as $post_type) { $args = array( 'post_type' => $post_type, ); $plugin_admin = new MyPlugin_Admin( $this->get_plugin_name(), $this->get_version(), $args ); $this->loader->add_action("views_edit-{$post_type}", $plugin_admin, 'some_function'); } 

And it works! Is that the correct way to do this?

Thanks Paul, you led me to the solution.

What I did

In class-mypluging-admin.php, I added this:

/** * Additional arguments for this plugin. * * @since 1.0.0 * @access private * @var array $args The current arguments of this plugin. */ private $args; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. * @param array $args The additional arguments of this plugin. */ public function __construct( $plugin_name, $version, $args = null ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->args = $args; } 

Then for the functions in class-mypluging-admin.php

function some_function( $views ) { if( !isset($this->args['post_type'])) throw new Exception('Argument missing.');; $post_type = $this->args['post_type']; ... } 

In class-mypluging.php, I do this:

foreach($post_types as $post_type) { $args = array( 'post_type' => $post_type, ); $plugin_admin = new MyPlugin_Admin( $this->get_plugin_name(), $this->get_version(), $args ); $this->loader->add_action("views_edit-{$post_type}", $plugin_admin, 'some_function'); } 

And it works! Is that the correct way to do this?

added 107 characters in body
Source Link
Tom
  • 1
  • 1

Thanks Paul, you led me to the solution.

What I did

In class-mypluging-admin.php, I added this:

/** * Additional arguments for this plugin. * * @since 1.0.0 * @access publicprivate * @var array $args The current arguments of this plugin. */ publicprivate $args; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. * @param array $args The additional arguments of this plugin. */ public function __construct( $plugin_name, $version, $args = null ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->args = $args; } 

Then for the functions in class-mypluging-admin.php

function some_function( $views ) { if( !isset($this->args['post_type'])) throw new Exception('Argument missing.');; $post_type = $this->args['post_type']; ... } 

In class-mypluging.php, I do this:

foreach($values as $post_type) {  $args = array( 'post_type' => $post_type, ); $plugin_admin = new MyPlugin_Admin( $this->args>get_plugin_name(), $this->get_version(), =$args $args;);  $this->loader->add_action("views_edit-{$post_type}", $plugin_admin, 'some_function');  } 

And it works! Is that the correct way to do this?

Thanks Paul, you led me to the solution.

What I did

In class-mypluging-admin.php, I added this:

/** * Additional arguments for this plugin. * * @since 1.0.0 * @access public * @var array $args The current arguments of this plugin. */ public $args; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. * @param array $args The additional arguments of this plugin. */ public function __construct( $plugin_name, $version, $args = null ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->args = $args; } 

Then for the functions in class-mypluging-admin.php

function some_function( $views ) { if( !isset($this->args['post_type'])) throw new Exception('Argument missing.');; $post_type = $this->args['post_type']; ... } 

In class-mypluging.php, I do this:

 $args = array( 'post_type' => $post_type, ); $plugin_admin->args = $args; $this->loader->add_action("views_edit-{$post_type}", $plugin_admin, 'some_function'); 

And it works! Is that the correct way to do this?

Thanks Paul, you led me to the solution.

What I did

In class-mypluging-admin.php, I added this:

/** * Additional arguments for this plugin. * * @since 1.0.0 * @access private * @var array $args The current arguments of this plugin. */ private $args; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. * @param array $args The additional arguments of this plugin. */ public function __construct( $plugin_name, $version, $args = null ) { $this->plugin_name = $plugin_name; $this->version = $version; $this->args = $args; } 

Then for the functions in class-mypluging-admin.php

function some_function( $views ) { if( !isset($this->args['post_type'])) throw new Exception('Argument missing.');; $post_type = $this->args['post_type']; ... } 

In class-mypluging.php, I do this:

foreach($values as $post_type) {  $args = array( 'post_type' => $post_type, ); $plugin_admin = new MyPlugin_Admin( $this->get_plugin_name(), $this->get_version(), $args );  $this->loader->add_action("views_edit-{$post_type}", $plugin_admin, 'some_function');  } 

And it works! Is that the correct way to do this?

added 90 characters in body
Source Link
Tom
  • 1
  • 1
Loading
edited body
Source Link
Tom
  • 1
  • 1
Loading
Source Link
Tom
  • 1
  • 1
Loading